-
Notifications
You must be signed in to change notification settings - Fork 54
164 lines (142 loc) · 5.97 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Build and upload the project by pushing tags
name: Build project & release
on:
push:
tags:
- '*'
jobs:
variables:
name: Define variables 🔗
runs-on: ubuntu-latest
outputs:
UNITY_VERSION: ${{ steps.set_unity_version.outputs.VERSION }}
TAG: ${{ steps.set_tag.outputs.VERSION }}
BUILD_NAME: ${{ steps.set_build_name.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Set unity version
id: set_unity_version
run: |
UNITY_VERSION=$(sed -n 's/^\m_EditorVersion: //p'< ./ProjectSettings/ProjectVersion.txt)
echo "VERSION=$UNITY_VERSION" >> $GITHUB_OUTPUT
- name: Set tag
id: set_tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Set target name
id: set_build_name
run: echo "VERSION=WebGL-${{ steps.set_tag.outputs.VERSION }}" >> $GITHUB_OUTPUT
- name: Log variables
run: |
echo "UNITY_VERSION -> ${{ steps.set_unity_version.outputs.VERSION }}"
echo "TAG -> ${{ steps.set_tag.outputs.VERSION }}"
echo "BUILD_NAME -> ${{ steps.set_build_name.outputs.VERSION }}"
tagVersionMatchTest:
needs: [ variables ]
name: Check tag version match ☑
runs-on: ubuntu-latest
steps:
- name: Log tag and version
run: echo "Github tag '${{ needs.variables.outputs.TAG }}' has to start with unity version '${{ needs.variables.outputs.UNITY_VERSION }}'"
- name: Version match ✔
if: startsWith(${{ needs.variables.outputs.TAG }}, {{ needs.variables.outputs.UNITY_VERSION }}
run: echo "Versions are matching 🥳"
- name: Version missmatch ❌
if: ${{ !startsWith(needs.variables.outputs.TAG, needs.variables.outputs.UNITY_VERSION) }}
uses: actions/github-script@v4
with:
script: |
core.setFailed('Unity version does not match tag version')
buildProject:
name: Create Unity WebGL Build 🏗
# only build with additional parameters, the tag alone should only create a release draft
if: ${{ needs.variables.outputs.TAG != needs.variables.outputs.UNITY_VERSION }}
needs: [ variables ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
# Unity 2020 cache is not compatible with older versions
- name: Unity Library Cache 2020 or higher
if: ${{ !startsWith(needs.variables.outputs.UNITY_VERSION, '201') }}
uses: actions/cache@v4
with:
path: Library
key: Library-202x-WebGL
restore-keys: Library-202x-
- name: Unity Library Cache 2019 or lower
if: ${{ startsWith(needs.variables.outputs.UNITY_VERSION, '201') }}
uses: actions/cache@v4
with:
path: Library
key: Library-201x-WebGL
restore-keys: Library-201x-
- name: Build project
uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
buildMethod: UnityBuilderAction.BuildScript.BuildWithCommandlineArgs
customParameters: -tag ${{ needs.variables.outputs.TAG }}
targetPlatform: WebGL
versioning: None
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
- uses: actions/upload-artifact@v4
with:
name: ${{ needs.variables.outputs.BUILD_NAME }}
path: build/WebGL
createRelease:
name: Create Github release 🐙
# only run for the pure tag without build parameters
if: ${{ needs.variables.outputs.TAG == needs.variables.outputs.UNITY_VERSION }}
needs: [ variables ]
runs-on: ubuntu-latest
steps:
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body: |
## Changes
*
[${{ needs.variables.outputs.UNITY_VERSION }}-webgl2](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-webgl2/)
[${{ needs.variables.outputs.UNITY_VERSION }}-webgl1](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-webgl1/)
[${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl2 Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl2/)
[${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl1 Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl1/)
[${{ needs.variables.outputs.UNITY_VERSION }}-minsize-webgl1 Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-minsize-webgl1/)
draft: true
deployOnServer:
name: Deploy on server 🚀
needs: [ variables, buildProject ]
# Guarded by username, you will need to remove or replace the line for your fork
if: ${{ github.repository_owner == 'JohannesDeml' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ needs.variables.outputs.BUILD_NAME }}
path: build
- name: Display structure of root files
run: ls -R
working-directory: build/${{ needs.variables.outputs.BUILD_NAME }}
- name: Deploy ⤴
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
port: 21
protocol: ftps
local-dir: ./build/${{ needs.variables.outputs.BUILD_NAME }}/
server-dir: ./${{ needs.variables.outputs.TAG }}/
# Make sure old files are deleted (e.g. created with name files as hashes)
dangerous-clean-slate: true