Skip to content

Commit 79e45a9

Browse files
committed
Add github workflow for automated builds and deployments 🚀
1 parent 1902871 commit 79e45a9

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

.github/workflows/activation.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Get Unity license activation file 🔑
2+
3+
on:
4+
workflow_dispatch: {}
5+
jobs:
6+
activation:
7+
name: Request manual activation file 🔑
8+
runs-on: ubuntu-latest
9+
steps:
10+
# Request manual activation file
11+
- name: Request manual activation file
12+
id: getManualLicenseFile
13+
uses: game-ci/unity-request-activation-file@v2
14+
# Upload artifact (Unity_v20XX.X.XXXX.alf)
15+
- name: Expose as artifact
16+
uses: actions/upload-artifact@v2
17+
with:
18+
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
19+
path: ${{ steps.getManualLicenseFile.outputs.filePath }}

.github/workflows/release.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Build project & release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
variables:
10+
name: Define variables 🔗
11+
runs-on: ubuntu-latest
12+
outputs:
13+
UNITY_VERSION: ${{ steps.set_unity_version.outputs.VERSION }}
14+
TAG: ${{ steps.set_tag.outputs.VERSION }}
15+
TARGET_NAME: ${{ steps.set_target_name.outputs.VERSION }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
lfs: true
21+
22+
- name: Set unity version
23+
id: set_unity_version
24+
run: |
25+
UNITY_VERSION=$(sed -n 's/^\m_EditorVersion: //p'< ./ProjectSettings/ProjectVersion.txt)
26+
echo "::set-output name=VERSION::$UNITY_VERSION"
27+
28+
- name: Set tag
29+
id: set_tag
30+
run: echo "::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}"
31+
32+
- name: Set target name
33+
id: set_target_name
34+
run: echo "::set-output name=VERSION::${{ steps.set_tag.outputs.VERSION }}"
35+
36+
- name: Log variables
37+
run: |
38+
echo "Unity Version is ${{ steps.set_unity_version.outputs.VERSION }}"
39+
echo "Tag is ${{ steps.set_tag.outputs.VERSION }}"
40+
echo "Target name is ${{ steps.set_target_name.outputs.VERSION }}"
41+
42+
tagVersionMatchTest:
43+
needs: [ variables ]
44+
name: Check tag version match ☑
45+
runs-on: ubuntu-latest
46+
steps:
47+
48+
- name: Log tag and version
49+
run: echo "Github tag '${{ needs.variables.outputs.TAG }}' has to start with unity version '${{ needs.variables.outputs.UNITY_VERSION }}'"
50+
51+
- name: Version match ✔
52+
if: startsWith(${{ needs.variables.outputs.TAG }}, {{ needs.variables.outputs.UNITY_VERSION }}
53+
run: echo "Versions are matching 🥳"
54+
55+
- name: Version missmatch ❌
56+
if: ${{ !startsWith(needs.variables.outputs.TAG, needs.variables.outputs.UNITY_VERSION) }}
57+
uses: actions/github-script@v3
58+
with:
59+
script: |
60+
core.setFailed('Unity version does not match tag version')
61+
62+
buildProject:
63+
name: Create Unity WebGL Build 🏗
64+
needs: [ variables ]
65+
runs-on: ubuntu-latest
66+
strategy:
67+
fail-fast: false
68+
steps:
69+
- uses: actions/checkout@v2
70+
with:
71+
fetch-depth: 0
72+
lfs: true
73+
74+
- uses: actions/cache@v2
75+
with:
76+
path: Library
77+
key: Library-WebGL
78+
restore-keys: Library-
79+
80+
- name: Build project
81+
uses: game-ci/unity-builder@v2
82+
env:
83+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
84+
with:
85+
targetPlatform: WebGL
86+
87+
- uses: actions/upload-artifact@v2
88+
with:
89+
name: WebGL-${{ needs.variables.outputs.TARGET_NAME }}
90+
path: build/WebGL
91+
92+
createRelease:
93+
name: Create Github release 🐙
94+
# only run for the main build, the others will be added to the release manually
95+
if: ${{ needs.variables.outputs.TAG == needs.variables.outputs.UNITY_VERSION }}
96+
needs: [ variables, buildProject ]
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/download-artifact@v2
100+
with:
101+
name: WebGL-${{ needs.variables.outputs.TARGET_NAME }}
102+
103+
- name: Change folder name
104+
run: mv WebGL WebGL-LoadingTest-${{ needs.variables.outputs.TARGET_NAME }}
105+
106+
- name: Zip release
107+
run: zip -r WebGL-${{ needs.variables.outputs.TARGET_NAME }}.zip WebGL-LoadingTest-${{ needs.variables.outputs.TARGET_NAME }}
108+
109+
- name: Create Release
110+
uses: softprops/action-gh-release@v1
111+
with:
112+
files: WebGL-${{ needs.variables.outputs.TARGET_NAME }}.zip
113+
114+
deployOnServer:
115+
name: Deploy on server 🚀
116+
needs: [ variables, buildProject ]
117+
# Guarded by username, if you want to do something sinilar remove the next line
118+
if: ${{ github.repository_owner == 'JohannesDeml' }}
119+
runs-on: ubuntu-latest
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v2
123+
124+
- uses: actions/download-artifact@v2
125+
with:
126+
name: WebGL-${{ needs.variables.outputs.TARGET_NAME }}
127+
path: build
128+
129+
- name: Display structure of root files
130+
run: ls -R
131+
working-directory: build/WebGL
132+
133+
- name: Deploy ⤴
134+
uses: SamKirkland/[email protected]
135+
with:
136+
server: ${{ secrets.FTP_SERVER }}
137+
username: ${{ secrets.FTP_USER }}
138+
password: ${{ secrets.FTP_PASSWORD }}
139+
port: 21
140+
protocol: ftps
141+
local-dir: ./build/WebGL/
142+
server-dir: ./${{ needs.variables.outputs.TARGET_NAME }}/

0 commit comments

Comments
 (0)