-
Notifications
You must be signed in to change notification settings - Fork 1
227 lines (222 loc) · 7.84 KB
/
main.yml
File metadata and controls
227 lines (222 loc) · 7.84 KB
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
name: Create a snapshot release
on:
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
prepare:
name: Prepare the environment
runs-on: ubuntu-latest
steps:
- name: Checkout the master branch
uses: actions/checkout@v4
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v29
with:
nix_conf: |
require-sigs = false
- name: Enter CI tailored shell
uses: rrbutani/use-nix-shell-action@v1
with:
devShell: .#ciDefault
- name: Update Doom2D related inputs and populate environment variables
run: |
./game/bundle/scripts/mkEnv.bash
- name: Save updated flake.lock
uses: actions/upload-artifact@v4
with:
name: flake.lock
path: flake.lock
- name: Save release_body
uses: actions/upload-artifact@v4
with:
name: release_body
path: release_body
build:
name: Build
needs: prepare
runs-on: ubuntu-22.04
strategy:
matrix:
arch:
- android
- apple
- mingw
steps:
- name: Free space
run: | # stolen from https://github.com/easimon/maximize-build-space and https://github.com/actions/runner-images/issues/2840
echo "=== Before pruning ==="
df -h
sudo rm -rf /opt || :
sudo rm -rf /usr/share/dotnet || :
sudo rm -rf "/usr/local/share/boost" || :
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || :
sudo rm -rf /opt/hostedtoolcache/CodeQL || :
sudo rm -rf /usr/local/lib/android || :
sudo rm -rf /opt/ghc || :
sudo docker image prune --all --force || :
sudo docker builder prune -a || :
echo
echo "=== After pruning ==="
df -h
- name: Checkout the master branch
uses: actions/checkout@v4
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v30
with:
nix_conf: |
require-sigs = false
- name: Enter CI tailored shell
uses: rrbutani/use-nix-shell-action@v1
with:
devShell: .#ciDefault
- name: Calculate nixpkgs' lock hash
run: |
NIXPKGS_REV=$(nix flake metadata . --json 2>/dev/null | jq --raw-output '.locks.nodes."nixpkgs".locked.rev')
echo "NIXPKGS_REV=$NIXPKGS_REV" >> "$GITHUB_ENV"
- uses: actions/cache/restore@v4
name: Restore persistent cache
with:
path: /tmp/nixcache_${{ matrix.arch }}
key: ${{ runner.os }}-${{ env.NIXPKGS_REV }}-${{ matrix.arch }}
- name: Restore toolchain from cache
run: |
nix copy --all --from /tmp/nixcache_${{ matrix.arch }}
- name: Delete old flake.lock
run: |
rm -f flake.lock
- name: Restore updated flake.lock
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Populate environment variables
env:
UPDATE_FLAKE: 0
run: |
./game/bundle/scripts/mkEnv.bash
- name: Build debug APK
if: ${{ matrix.arch == 'android' }}
env:
BUNDLE_NAME: android.bundles.default
EMBED_BUILD_DATE: 1
run: |
./game/bundle/scripts/mkOverride.bash
cp result Doom2D-Forever.apk
- name: Upload debug APK
uses: actions/upload-artifact@v4
if: ${{ matrix.arch == 'android' }}
with:
name: Doom2D-Forever.apk
path: Doom2D-Forever.apk
if-no-files-found: error
- name: Build Windows x86 ZIP bundle
if: ${{ matrix.arch == 'mingw' }}
env:
BUNDLE_NAME: mingw32.bundles.zip
run: |
./game/bundle/scripts/mkOverride.bash
cp result doom2df_windows.x86.zip
- name: Upload Windows x86 ZIP bundle
uses: actions/upload-artifact@v4
if: ${{ matrix.arch == 'mingw' }}
with:
name: doom2df_windows.x86.zip
path: doom2df_windows.x86.zip
- name: Build Windows x86_64 ZIP bundle
if: ${{ matrix.arch == 'mingw' }}
env:
BUNDLE_NAME: mingw64.bundles.zip
run: |
./game/bundle/scripts/mkOverride.bash
cp result doom2df_win64.x86-64.zip
- name: Upload Windows x86_64 ZIP bundle
uses: actions/upload-artifact@v4
if: ${{ matrix.arch == 'mingw' }}
with:
name: doom2df_win64.x86-64.zip
path: doom2df_win64.x86-64.zip
- name: Build MacOS x86_64 ZIP bundle
if: ${{ matrix.arch == 'apple' }}
env:
BUNDLE_NAME: x86_64-apple-darwin.bundles.zip
run: |
./game/bundle/scripts/mkOverride.bash
cp result doom2df_macos.intel64.zip
- name: Upload MacOS x86_64 ZIP bundle
uses: actions/upload-artifact@v4
if: ${{ matrix.arch == 'apple' }}
with:
name: doom2df_macos.intel64.zip
path: doom2df_macos.intel64.zip
- name: Build MacOS aarch64 ZIP bundle
if: ${{ matrix.arch == 'apple' }}
env:
BUNDLE_NAME: arm64-apple-darwin.bundles.zip
run: |
./game/bundle/scripts/mkOverride.bash
cp result doom2df_macos.aarch64.zip
- name: Upload MacOS aarch64 ZIP bundle
uses: actions/upload-artifact@v4
if: ${{ matrix.arch == 'apple' }}
with:
name: doom2df_macos.aarch64.zip
path: doom2df_macos.aarch64.zip
- name: Build MacOS app bundle
if: ${{ matrix.arch == 'apple' }}
env:
BUNDLE_NAME: macOS.bundles.default
run: |
./game/bundle/scripts/mkOverride.bash
cp result Doom2D-Forever.dmg
- name: Upload MacOS app bundle
uses: actions/upload-artifact@v4
if: ${{ matrix.arch == 'apple' }}
with:
name: Doom2D-Forever.dmg
path: Doom2D-Forever.dmg
if-no-files-found: error
upload:
name: Create a new release
needs: build
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Download all artifacts in this run (release_body and artifacts)
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Calculate new build number
run: |
GITHUB_RESPONSE_FILE=github_response
TODAY=$(date +'%Y-%m-%d')
curl \
-H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/releases \
-H "Authorization: ${{ secrets.GITHUB_TOKEN }}" \
> $GITHUB_RESPONSE_FILE
TODAY_RELEASES_COUNT=$(jq --arg TODAY $TODAY '[.[] | select((.published_at | startswith($TODAY) ) )] | length' $GITHUB_RESPONSE_FILE)
THIS_RELEASE_COUNT=$(( $TODAY_RELEASES_COUNT + 1 ))
RELEASE_PREFIX="0.667b"
RELEASE_NAME="${RELEASE_PREFIX}-$(date +'%Y.%m.%d')-$THIS_RELEASE_COUNT"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
with:
artifacts: doom2df_windows.x86.zip, Doom2D-Forever.apk, doom2df_win64.x86-64.zip, doom2df_macos.intel64.zip, doom2df_macos.aarch64.zip, Doom2D-Forever.dmg
replacesArtifacts: false
removeArtifacts: false
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.RELEASE_NAME }}
bodyFile: release_body
tag: ${{ env.RELEASE_NAME }}
immutableCreate: true
allowUpdates: false
artifactErrorsFailBuild: true
- name: Delete releases and workflows runs
uses: ophub/delete-releases-workflows@main
with:
delete_releases: true
releases_keep_latest: 16
delete_workflows: true
workflows_keep_day: 10
gh_token: ${{ secrets.GITHUB_TOKEN }}