-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (176 loc) · 6.17 KB
/
build.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: project builder
on:
workflow_dispatch:
inputs:
repository:
type: string
description: path to github project, in format <owner>/<repo>
required: true
default: plyr4/unity-ufo
ref:
type: string
description: ref to use when cloning the project. default is the head ref of the target repository
required: false
deploy-to-pages:
type: boolean
description: deploy to gh-pages branch for <owner>/<repo> after build
default: true
pages-deploy-branch:
type: string
description: branch to use when deploying to pages. default is gh-pages
required: false
default: gh-pages
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: build
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.targetPlatform }} build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneWindows64
- StandaloneLinux64
- WebGL
steps:
- name: clone project
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || '' }}
repository: ${{ github.event.inputs.repository }}
lfs: true
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: write git info
id: git
run: |
echo "commit_hash=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "commit_message=$(git log -1 --pretty=%B)" >> "$GITHUB_OUTPUT"
- name: free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: upload webgl template
uses: actions/upload-artifact@v4
if: matrix.targetPlatform == 'WebGL'
with:
name: WebGL-Template
path: WebGL
- name: cache Library
uses: actions/cache@v3
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-${{ matrix.targetPlatform }}
- name: build project for ${{ matrix.targetPlatform }}
uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
- name: upload ${{ matrix.targetPlatform }} build
uses: actions/upload-artifact@v4
id: upload
with:
name: Build-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
- name: archive ${{ matrix.targetPlatform }} release
run: cd build/${{ matrix.targetPlatform }} && zip -r ../../neebo-${{ matrix.targetPlatform }}.zip .
- name: publish ${{ matrix.targetPlatform }} pre-release
uses: softprops/action-gh-release@v1
id: release
with:
prerelease: true
name: ${{ github.event.inputs.repository }}-${{ matrix.targetPlatform }}
tag_name: ${{ github.event.inputs.repository }}-${{ matrix.targetPlatform }}
files: neebo-${{ matrix.targetPlatform }}.zip
fail_on_unmatched_files: true
- name: write matrix outputs
uses: cloudposse/github-action-matrix-outputs-write@main
id: out
with:
matrix-step-name: release
matrix-key: ${{ matrix.targetPlatform }}
outputs: |-
releases: ${{ steps.release.outputs.assets }}
commit_hash: "${{ steps.git.outputs.commit_hash }}"
commit_message: "${{ steps.git.outputs.commit_message }}"
read:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.deploy-to-pages == 'true' }}
steps:
- name: read matrix outputs
uses: cloudposse/github-action-matrix-outputs-read@main
id: read
with:
matrix-step-name: release
outputs:
result: ${{ steps.read.outputs.result }}
commit_hash: "${{ steps.read.outputs.commit_hash }}"
commit_message: "${{ steps.read.outputs.commit_message }}"
deploy:
needs: read
runs-on: ubuntu-latest
if: ${{ github.event.inputs.deploy-to-pages == 'true' }}
steps:
- name: clone target repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.repository }}
ref: gh-pages
token: ${{ secrets.PAT_TOKEN }}
- name: clear existing content
run: |
mv .git ../.git
rm -rf *
mv ../.git .git
- name: download webgl build
uses: actions/download-artifact@v4
with:
name: Build-WebGL
path: .
- name: unpack webgl build
run: |
ls -lar .
ls -lar WebGL
cp -r WebGL/Build .
rm -rf WebGL
- name: download webgl template
uses: actions/download-artifact@v4
with:
name: WebGL-Template
path: .
- name: substitute env on index.html
uses: danielr1996/envsubst-action@1.1.0
env:
LINUX_BUILD_LINK: ${{ fromJson(needs.read.outputs.result).releases.StandaloneLinux64[0].browser_download_url }}
WINDOWS_BUILD_LINK: ${{ fromJson(needs.read.outputs.result).releases.StandaloneWindows64[0].browser_download_url }}
BUILD_COMMIT: "${{ fromJson(needs.read.outputs.result).commit_hash.WebGL }}"
BUILD_COMMIT_MESSAGE: "${{ fromJson(needs.read.outputs.result).commit_message.WebGL }}"
with:
input: ./index.html
output: ./index.html
- name: commit static site
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "publishing static site"
- name: push static site to ${{ github.event.inputs.repository }} on gh-pages
uses: ad-m/github-push-action@master
with:
repository: ${{ github.event.inputs.repository }}
branch: ${{ github.event.inputs.pages-deploy-branch || 'gh-pages' }}
github_token: ${{ secrets.PAT_TOKEN }}