Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.

Commit 11f3234

Browse files
author
doomy
committed
added template for auto uploading
1 parent b018913 commit 11f3234

File tree

1 file changed

+289
-0
lines changed

1 file changed

+289
-0
lines changed

.github/workflows/release.yaml

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
# update with the name of the main binary
10+
binary: bevy_github_ci_template
11+
add_binaries_to_github_release: true
12+
#itch_target: <itch.io-username>/<game-name>
13+
14+
15+
jobs:
16+
17+
# Build for wasm
18+
release-wasm:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: olegtarasov/[email protected]
23+
id: get_version
24+
- uses: actions/checkout@v4
25+
- uses: dtolnay/rust-toolchain@stable
26+
with:
27+
targets: wasm32-unknown-unknown
28+
- name: install wasm-bindgen-cli
29+
run: |
30+
cargo install wasm-bindgen-cli
31+
32+
- name: Build
33+
run: |
34+
cargo build --release --target wasm32-unknown-unknown
35+
36+
- name: Prepare package
37+
run: |
38+
wasm-bindgen --no-typescript --out-name bevy_game --out-dir wasm --target web target/wasm32-unknown-unknown/release/${{ env.binary }}.wasm
39+
cp -r assets wasm/
40+
41+
- name: Package as a zip
42+
working-directory: ./wasm
43+
run: |
44+
zip --recurse-paths ../${{ env.binary }}.zip .
45+
46+
- name: Upload binaries to artifacts
47+
uses: actions/upload-artifact@v3
48+
with:
49+
path: ${{ env.binary }}.zip
50+
name: wasm
51+
retention-days: 1
52+
53+
- name: Upload binaries to release
54+
if: ${{ env.add_binaries_to_github_release == 'true' }}
55+
uses: svenstaro/upload-release-action@v2
56+
with:
57+
repo_token: ${{ secrets.GITHUB_TOKEN }}
58+
file: ${{ env.binary }}.zip
59+
asset_name: ${{ env.binary }}-wasm-${{ steps.get_version.outputs.tag }}.zip
60+
tag: ${{ github.ref }}
61+
overwrite: true
62+
63+
# Build for Linux
64+
release-linux:
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- uses: olegtarasov/[email protected]
69+
id: get_version
70+
- uses: actions/checkout@v4
71+
- uses: dtolnay/rust-toolchain@stable
72+
with:
73+
targets: x86_64-unknown-linux-gnu
74+
- name: install dependencies
75+
run: |
76+
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
77+
78+
- name: Build
79+
run: |
80+
cargo build --release --target x86_64-unknown-linux-gnu
81+
82+
- name: Prepare package
83+
run: |
84+
mkdir linux
85+
cp target/x86_64-unknown-linux-gnu/release/${{ env.binary }} linux/
86+
cp -r assets linux/
87+
88+
- name: Package as a zip
89+
working-directory: ./linux
90+
run: |
91+
zip --recurse-paths ../${{ env.binary }}.zip .
92+
93+
- name: Upload binaries to artifacts
94+
uses: actions/upload-artifact@v3
95+
with:
96+
path: ${{ env.binary }}.zip
97+
name: linux
98+
retention-days: 1
99+
100+
- name: Upload binaries to release
101+
if: ${{ env.add_binaries_to_github_release == 'true' }}
102+
uses: svenstaro/upload-release-action@v2
103+
with:
104+
repo_token: ${{ secrets.GITHUB_TOKEN }}
105+
file: ${{ env.binary }}.zip
106+
asset_name: ${{ env.binary }}-linux-${{ steps.get_version.outputs.tag }}.zip
107+
tag: ${{ github.ref }}
108+
overwrite: true
109+
110+
# Build for Windows
111+
release-windows:
112+
runs-on: windows-latest
113+
114+
steps:
115+
- uses: olegtarasov/[email protected]
116+
id: get_version
117+
- uses: actions/checkout@v4
118+
- uses: dtolnay/rust-toolchain@stable
119+
with:
120+
targets: x86_64-pc-windows-msvc
121+
122+
- name: Build
123+
run: |
124+
cargo build --release --target x86_64-pc-windows-msvc
125+
126+
- name: Prepare package
127+
run: |
128+
mkdir windows
129+
cp target/x86_64-pc-windows-msvc/release/${{ env.binary }}.exe windows/
130+
cp -r assets windows/
131+
132+
- name: Package as a zip
133+
run: |
134+
Compress-Archive -Path windows/* -DestinationPath ${{ env.binary }}.zip
135+
136+
- name: Upload binaries to artifacts
137+
uses: actions/upload-artifact@v3
138+
with:
139+
path: ${{ env.binary }}.zip
140+
name: windows
141+
retention-days: 1
142+
143+
- name: Upload binaries to release
144+
if: ${{ env.add_binaries_to_github_release == 'true' }}
145+
uses: svenstaro/upload-release-action@v2
146+
with:
147+
repo_token: ${{ secrets.GITHUB_TOKEN }}
148+
file: ${{ env.binary }}.zip
149+
asset_name: ${{ env.binary }}-windows-${{ steps.get_version.outputs.tag }}.zip
150+
tag: ${{ github.ref }}
151+
overwrite: true
152+
153+
# Build for MacOS x86_64
154+
release-macOS-intel:
155+
runs-on: macOS-latest
156+
157+
steps:
158+
- uses: olegtarasov/[email protected]
159+
id: get_version
160+
- uses: actions/checkout@v4
161+
- uses: dtolnay/rust-toolchain@stable
162+
with:
163+
targets: x86_64-apple-darwin
164+
- name: Environment Setup
165+
run: |
166+
export CFLAGS="-fno-stack-check"
167+
export MACOSX_DEPLOYMENT_TARGET="10.9"
168+
169+
- name: Build
170+
run: |
171+
cargo build --release --target x86_64-apple-darwin
172+
173+
- name: Prepare Package
174+
run: |
175+
mkdir -p ${{ env.binary }}.app/Contents/MacOS
176+
cp target/x86_64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/
177+
cp -r assets ${{ env.binary }}.app/Contents/MacOS/
178+
hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}-macOS-intel.dmg
179+
180+
- name: Upload binaries to artifacts
181+
uses: actions/upload-artifact@v3
182+
with:
183+
path: ${{ env.binary }}-macOS-intel.dmg
184+
name: macOS-intel
185+
retention-days: 1
186+
187+
- name: Upload binaries to release
188+
if: ${{ env.add_binaries_to_github_release == 'true' }}
189+
uses: svenstaro/upload-release-action@v2
190+
with:
191+
repo_token: ${{ secrets.GITHUB_TOKEN }}
192+
file: ${{ env.binary }}-macOS-intel.dmg
193+
asset_name: ${{ env.binary }}-macOS-intel-${{ steps.get_version.outputs.tag }}.dmg
194+
tag: ${{ github.ref }}
195+
overwrite: true
196+
197+
# Build for MacOS Apple Silicon
198+
release-macOS-apple-silicon:
199+
runs-on: macOS-latest
200+
201+
steps:
202+
- uses: olegtarasov/[email protected]
203+
id: get_version
204+
- uses: actions/checkout@v4
205+
- uses: dtolnay/rust-toolchain@stable
206+
with:
207+
targets: aarch64-apple-darwin
208+
- name: Environment
209+
# macOS 11 was the first version to support ARM
210+
run: |
211+
export MACOSX_DEPLOYMENT_TARGET="11"
212+
213+
- name: Build
214+
run: |
215+
cargo build --release --target aarch64-apple-darwin
216+
217+
- name: Prepare Package
218+
run: |
219+
mkdir -p ${{ env.binary }}.app/Contents/MacOS
220+
cp target/aarch64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/
221+
cp -r assets ${{ env.binary }}.app/Contents/MacOS/
222+
hdiutil create -fs HFS+ -volname "${{ env.binary }}-macOS-apple-silicon" -srcfolder ${{ env.binary }}.app ${{ env.binary }}-macOS-apple-silicon.dmg
223+
224+
- name: Upload binaries to artifacts
225+
uses: actions/upload-artifact@v3
226+
with:
227+
path: ${{ env.binary }}-macOS-apple-silicon.dmg
228+
name: macOS-apple-silicon
229+
retention-days: 1
230+
231+
- name: Upload binaries to release
232+
if: ${{ env.add_binaries_to_github_release == 'true' }}
233+
uses: svenstaro/upload-release-action@v2
234+
with:
235+
repo_token: ${{ secrets.GITHUB_TOKEN }}
236+
file: ${{ env.binary }}-macOS-apple-silicon.dmg
237+
asset_name: ${{ env.binary }}-macOS-apple-silicon-${{ steps.get_version.outputs.tag }}.dmg
238+
tag: ${{ github.ref }}
239+
overwrite: true
240+
241+
check-if-upload-to-itch-is-configured:
242+
runs-on: ubuntu-latest
243+
outputs:
244+
should-upload: ${{ steps.check-env.outputs.has-itch-target }}
245+
steps:
246+
- id: check-env
247+
run: |
248+
if [[ -z "$itch_target" ]]; then
249+
echo "has-itch-target=no" >> $GITHUB_OUTPUT
250+
else
251+
echo "has-itch-target=yes" >> $GITHUB_OUTPUT
252+
fi
253+
254+
upload-to-itch:
255+
runs-on: ubuntu-latest
256+
needs:
257+
- check-if-upload-to-itch-is-configured
258+
- release-wasm
259+
- release-linux
260+
- release-windows
261+
- release-macOS-intel
262+
- release-macOS-apple-silicon
263+
if: ${{ needs.check-if-upload-to-itch-is-configured.outputs.should-upload == 'yes' }}
264+
265+
steps:
266+
- name: Download artifacts
267+
uses: actions/download-artifact@v3
268+
with:
269+
path: ./builds
270+
271+
- name: Install butler
272+
run: |
273+
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
274+
unzip butler.zip
275+
chmod +x butler
276+
./butler -V
277+
- uses: olegtarasov/[email protected]
278+
id: get_version
279+
- name: Upload to itch.io
280+
env:
281+
BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }}
282+
run: |
283+
for channel in $(ls builds); do
284+
./butler push \
285+
--fix-permissions \
286+
--userversion="${{ steps.get_version.outputs.tag }}" \
287+
builds/$channel/* \
288+
${{ env.itch_target }}:$channel
289+
done

0 commit comments

Comments
 (0)