generated from NiklasEi/bevy_game_template
-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (208 loc) · 8.02 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
name: release-flow
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
inputs:
version:
description: 'Version - in the form of v1.2.3'
required: true
type: string
env:
# heads-up: this value is used as a pattern in an sed command as a workaround for a trunk issue
# if you use special characters, take a look at the 'Make paths relative' step in the 'build-web' job
GAME_EXECUTABLE_NAME: drug_test
GAME_OSX_APP_NAME: DrugTest
permissions:
contents: write
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- name: Get tag
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
outputs:
version: ${{ inputs.version || steps.tag.outputs.tag }}
build-macOS:
runs-on: macos-latest
needs: get-version
env:
# macOS 11.0 Big Sur is the first version to support universal binaries
MACOSX_DEPLOYMENT_TARGET: 11.0
VERSION: ${{needs.get-version.outputs.version}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Remove build script
run: |
rm build.rs
- name: Install rust toolchain for Apple Silicon
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-apple-darwin
override: true
- name: Build release for Apple Silicon
run: |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --release --target=aarch64-apple-darwin
- name: Install rust toolchain for Apple x86
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
override: true
- name: Build release for x86 Apple
run: |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --release --target=x86_64-apple-darwin
- name: Create Universal Binary
run: |
lipo -create -output target/release/${{ env.GAME_EXECUTABLE_NAME }} target/aarch64-apple-darwin/release/${{ env.GAME_EXECUTABLE_NAME }} target/x86_64-apple-darwin/release/${{ env.GAME_EXECUTABLE_NAME }}
- name: Create release
run: |
mkdir -p build/macos/src/Game.app/Contents/MacOS/assets
cp -r assets/ build/macos/src/Game.app/Contents/MacOS/assets
cp -r credits/ build/macos/src/Game.app/Contents/MacOS/credits
cp target/release/${{ env.GAME_EXECUTABLE_NAME }} build/macos/src/Game.app/Contents/MacOS/
strip build/macos/src/Game.app/Contents/MacOS/${{ env.GAME_EXECUTABLE_NAME }}
mv build/macos/src/Game.app build/macos/src/${{ env.GAME_OSX_APP_NAME }}.app
ln -s /Applications build/macos/src/
hdiutil create -fs HFS+ -volname "${{ env.GAME_OSX_APP_NAME }}" -srcfolder build/macos/src ${{ env.GAME_EXECUTABLE_NAME }}.dmg
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.GAME_EXECUTABLE_NAME }}.dmg
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_macOS.dmg
release_name: ${{ env.VERSION }}
overwrite: true
build-linux:
runs-on: ubuntu-latest
needs: get-version
env:
VERSION: ${{needs.get-version.outputs.version}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev
- name: Build release
run: |
cargo build --release
- name: Prepare release
run: |
strip target/release/${{ env.GAME_EXECUTABLE_NAME }}
chmod +x target/release/${{ env.GAME_EXECUTABLE_NAME }}
mv target/release/${{ env.GAME_EXECUTABLE_NAME }} .
- name: Bundle release
run: |
tar -czf ${{ env.GAME_EXECUTABLE_NAME }}_linux.tar.gz ${{ env.GAME_EXECUTABLE_NAME }} assets credits
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.GAME_EXECUTABLE_NAME }}_linux.tar.gz
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_linux.tar.gz
release_name: ${{ env.VERSION }}
overwrite: true
build-windows:
runs-on: windows-latest
needs: get-version
env:
VERSION: ${{needs.get-version.outputs.version}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install dotnet
uses: actions/setup-dotnet@v3
with:
global-json-file: build/windows/installer/global.json
- name: Build release
run: |
cargo build --release
- name: Prepare release
run: |
mkdir target/release/assets && cp -r assets target/release/assets
mkdir target/release/credits && cp -r credits target/release/credits
- name: Zip release
uses: vimtor/action-zip@v1
with:
files: target/release/assets/ target/release/credits/ target/release/${{ env.GAME_EXECUTABLE_NAME }}.exe
dest: ${{ env.GAME_EXECUTABLE_NAME }}_windows.zip
- name: Create Installer
run: dotnet build -c Release build/windows/installer/Installer.wixproj --output installer
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.GAME_EXECUTABLE_NAME }}_windows.zip
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_windows.zip
tag: ${{ github.ref }}
overwrite: true
- name: Upload installer
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: installer/en-US/installer.msi
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ steps.tag.outputs.tag }}_windows.msi
release_name: ${{ env.VERSION }}
overwrite: true
build-web:
runs-on: ubuntu-latest
needs: get-version
env:
VERSION: ${{needs.get-version.outputs.version}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev
- name: Install trunk
uses: jetli/trunk-action@v0.1.0
with:
version: latest
- name: Add wasm target
run: |
rustup target add wasm32-unknown-unknown
- name: Build Release
run: |
trunk build --release
- name: Optimize Wasm
uses: NiklasEi/wasm-opt-action@v2
with:
file: dist/*.wasm
# Trunk cannot import assets from relative paths (see e.g. https://github.com/thedodd/trunk/issues/395)
# On sites like itch.io, we don't know on which base path the game gets served, so we need to rewrite all links to be relative
- name: Make paths relative
run: |
sed -i 's/\/index/.\/index/g' dist/index.html
sed -i 's/\/${{ env.GAME_EXECUTABLE_NAME }}/.\/${{ env.GAME_EXECUTABLE_NAME }}/g' dist/index.html
- name: Zip release
uses: vimtor/action-zip@v1
with:
files: dist/
dest: ${{ env.GAME_EXECUTABLE_NAME }}_web.zip
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.GAME_EXECUTABLE_NAME }}_web.zip
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_web.zip
release_name: ${{ env.VERSION }}
overwrite: true