-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (257 loc) · 9.56 KB
/
release.yaml
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: Release
on:
push:
tags:
- "*"
workflow_dispatch: {}
env:
# update with the name of the main binary
add_binaries_to_github_release: github.ref_type == 'tag' && github.ref_name && true
release_version: ${{ (github.ref_type == 'tag' && github.ref_name) || format('{0}_{1}', github.ref_name, github.run_number) }}
concurrency:
group: release
cancel-in-progress: true
jobs:
setup-build-name:
outputs:
binary: ${{ steps.setup-build-name.outputs.BIN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: setup-build-name
run: |
NAME=$( sed -n 's/^name = "\(.*\)"/\1/p' < ./Cargo.toml )
echo "binary: _$NAME_"
echo "BIN=$NAME" >> $GITHUB_OUTPUT
# Build for wasm
release-wasm:
runs-on: ubuntu-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: wasm32-unknown-unknown
- name: install dependencies
run: |
sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev alsa
- name: binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: wasm-bindgen-cli
run: cargo binstall -y wasm-bindgen-cli
- name: Build
run: |
chmod +x ./web-build.sh
./web-build.sh
- name: Package as a zip
working-directory: ./dist
run: |
zip --recurse-paths ../${{ needs.setup-build-name.outputs.binary}}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.zip
name: wasm
- name: Fix permissions
run: |
chmod -c -R +rX "dist/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./dist
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.zip
asset_name: ${{ needs.setup-build-name.outputs.binary}}-wasm-${{ env.release_version }}.zip
tag: ${{ env.release_version }}
overwrite: true
# Build for Linux
release-linux:
runs-on: ubuntu-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
- name: install dependencies
run: |
sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- name: Build
run: |
cargo build --release --target x86_64-unknown-linux-gnu
- name: Prepare package
run: |
mkdir linux
cp target/x86_64-unknown-linux-gnu/release/${{ needs.setup-build-name.outputs.binary}} linux/
cp -r assets linux/
- name: Package as a zip
working-directory: ./linux
run: |
zip --recurse-paths ../${{ needs.setup-build-name.outputs.binary}}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.zip
name: linux
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.zip
asset_name: ${{ needs.setup-build-name.outputs.binary}}-linux-${{ env.release_version }}.zip
tag: ${{ env.release_version }}
overwrite: true
# Build for Windows
release-windows:
runs-on: windows-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-pc-windows-msvc
- name: Build
run: |
cargo build --release --target x86_64-pc-windows-msvc
- name: Prepare package
run: |
mkdir windows
cp target/x86_64-pc-windows-msvc/release/${{ needs.setup-build-name.outputs.binary}}.exe windows/
cp -r assets windows/
- name: Package as a zip
run: |
Compress-Archive -Path windows/* -DestinationPath ${{ needs.setup-build-name.outputs.binary}}.zip
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.zip
name: windows
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.zip
asset_name: ${{ needs.setup-build-name.outputs.binary}}-windows-${{ env.release_version }}.zip
tag: ${{ env.release_version }}
overwrite: true
# Build for macOS
release-macos:
runs-on: macOS-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-apple-darwin
- name: Environment Setup
run: |
export CFLAGS="-fno-stack-check"
export MACOSX_DEPLOYMENT_TARGET="10.9"
- name: Build
run: |
cargo build --release --target x86_64-apple-darwin
- name: Prepare Package
run: |
mkdir -p ${{ needs.setup-build-name.outputs.binary}}.app/Contents/MacOS
cp target/x86_64-apple-darwin/release/${{ needs.setup-build-name.outputs.binary}} ${{ needs.setup-build-name.outputs.binary}}.app/Contents/MacOS/
cp -r assets ${{ needs.setup-build-name.outputs.binary}}.app/Contents/MacOS/
hdiutil create -fs HFS+ -volname " ${{ needs.setup-build-name.outputs.binary}}" -srcfolder ${{ needs.setup-build-name.outputs.binary}}.app ${{ needs.setup-build-name.outputs.binary}}.dmg
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.dmg
name: mac
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.dmg
asset_name: ${{ needs.setup-build-name.outputs.binary}}-macos-${{ env.release_version }}.dmg
tag: ${{ env.release_version }}
overwrite: true
check-if-upload-to-itch-is-configured:
needs: setup-build-name
runs-on: ubuntu-latest
outputs:
should-upload: ${{ steps.check-env.outputs.has-itch-target }}
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- id: check-env
run: |
if [[ -z "$itch_target" ]]; then
echo "has-itch-target=no" >> $GITHUB_OUTPUT
else
echo "has-itch-target=yes" >> $GITHUB_OUTPUT
fi
- name: validate ref
run: echo "RELEASE - ${{ env.release_version}}"
upload-to-github:
runs-on: ubuntu-latest
needs: release-wasm
permissions:
pages: write # to deploy to Pages
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v2
with:
artifact_name: github-pages
upload-to-itch:
runs-on: ubuntu-latest
needs:
- check-if-upload-to-itch-is-configured
- release-wasm
- release-linux
- release-windows
- release-macos
if: ${{ needs.check-if-upload-to-itch-is-configured.outputs.should-upload == 'yes' }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./builds
- name: remove pages
run: rm -rf ./builds/github-pages
- name: Install butler
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
- name: Upload to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }}
run: |
for channel in $(ls builds); do
./butler push \
--fix-permissions \
--userversion="${{ env.release_version }}" \
builds/$channel/* \
${{ env.itch_target }}:$channel
done