-
-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (226 loc) · 8.41 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
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
name: build
on:
push:
paths:
- "**/*"
- "!.*"
- "!.github/**/*"
- "!README.md"
workflow_dispatch:
jobs:
assembling:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install NASM
uses: ilammy/setup-nasm@v1
- name: Assemble injections
shell: cmd
run: make src/inc/injections.inc
- name: Cache intermediate build results
uses: actions/cache/save@v4
with:
path: |
metadata
src
bin
key: intermediate1-${{ github.run_id }}-${{ github.run_attempt }}
resources:
runs-on: ubuntu-latest
steps:
- name: Checkout resource repository
uses: actions/checkout@v4
with:
repository: szapp/NinjaScripts
submodules: recursive
token: ${{ secrets.NINJA_LEGO_TOKEN }}
persist-credentials: false
- name: Build resource data
uses: kirides/vdfsbuilder@aaf901f0c98245af54102a1946d8be0e2e17ba36
with:
in: iklg.vm
out: iklg.data
ts: '2039-12-31 23:59:58'
- name: Move into the correct directory
run: |
mkdir -p src/inc
mv iklg.data src/inc
- name: Cache compiled resource data
uses: actions/cache/save@v4
with:
path: src/inc/iklg.data
key: resources-${{ github.run_id }}-${{ github.run_attempt }}
linking:
runs-on: windows-latest
needs: [assembling, resources]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch intermediate build results
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
metadata
src
bin
key: intermediate1-${{ github.run_id }}-${{ github.run_attempt }}
- name: Fetch compiled resource data
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
enableCrossOsArchive: true
path: src/inc/iklg.data
key: resources-${{ github.run_id }}-${{ github.run_attempt }}
- name: Install NASM
uses: ilammy/setup-nasm@v1
- name: Download GoDevTools and Ducible
run: |
Invoke-WebRequest http://godevtool.com/Golink.zip -OutFile golink.zip
Invoke-WebRequest http://godevtool.com/Gorc.zip -OutFile gorc.zip
Invoke-WebRequest https://github.com/jasonwhite/ducible/releases/download/v1.2.2/ducible-windows-Win32-Release.zip -OutFile ducible.zip
unzip golink.zip GoLink.exe
unzip gorc.zip GoRC.exe
unzip ducible.zip ducible.exe
- name: Assemble Ninja.dll
shell: cmd
run: make build/Ninja.dll
- name: Assemble BugslayerUtil.dll
shell: cmd
run: make build/BugslayerUtil.dll
- name: Cache intermediate build results
uses: actions/cache/save@v4
with:
# Cache all source files for make timestamps
path: |
metadata
LICENSE
src
bin
build
key: intermediate2-${{ github.run_id }}-${{ github.run_attempt }}
- name: Calculate checksum
run: |
$crc = crc32 build/Ninja.dll
echo "::notice title=Ninja.dll CRC32::0x$($crc.ToUpper())"
- name: Upload DLLs as workflow artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: ninja
path: build/*.dll
setup:
runs-on: windows-latest
needs: linking
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch intermediate build results
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
metadata
LICENSE
src
bin
build
key: intermediate2-${{ github.run_id }}-${{ github.run_attempt }}
- name: Build NSIS setup
shell: cmd
run: make all
- name: Cache build results
uses: actions/cache/save@v4
with:
enableCrossOsArchive: true
path: build
key: results-${{ github.run_id }}-${{ github.run_attempt }}
- name: Export version
shell: bash
run: |
source metadata
echo "VERSION=$VBASE.$VMAJOR.$VMINOR" >> $GITHUB_ENV
- name: Calculate checksum
run: |
$sha = (Get-FileHash build/Ninja-${{ env.VERSION }}.exe).Hash
echo "::notice title=Ninja-${{ env.VERSION }}.exe SHA-256::$sha"
- name: Upload setup as workflow artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: setup
path: build/Ninja-*.exe
deploy:
runs-on: ubuntu-latest
needs: setup
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Fetch build results
uses: actions/cache/restore@v4
with:
enableCrossOsArchive: true
fail-on-cache-miss: true
path: build
key: results-${{ github.run_id }}-${{ github.run_attempt }}
- name: Draft release
if: startsWith(github.ref, 'refs/tags/')
run: |
tag=${GITHUB_REF#refs/tags/}
changlogdate=$(date -d ${{ github.event.head_commit.timestamp }} +"%b-%-d-%Y")
changelogid="${tag//./}-${changlogdate,,}"
echo "VERSION=${tag/v/}" >> $GITHUB_ENV
echo "CHANGELOGID=${changelogid}" >> $GITHUB_ENV
notes="<!-- <div align=\"center\"><table width=\"100%\"><td><b>⚠ This version is outdated. Please use the <a href=\"https://github.com/szapp/Ninja/releases/latest\">lastest version</a> instead. ⚠ </b></td></table></div> -->"$'\n\n'"- [Change log](https://github.com/szapp/Ninja/wiki/Changelog#$changelogid)"$'\n'"- [Installation instructions](https://github.com/szapp/Ninja/wiki/Installation-(EN)#wiki-wrapper)"$'\n'"- [Check sums](https://github.com/szapp/Ninja/wiki/Checksums#wiki-wrapper)"
gh release create $tag -R ${{ github.repository }} -d --verify-tag --title "Ninja ${tag/v/}" --notes "$notes" build/Ninja-*.exe || echo "::error title=Release failed::Could not draft release for tag $tag"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Prepare Steam workshop upload
run: |
mkdir -p content/System
cp build/*.dll content/System/
curl -sLO https://github.com/user-attachments/files/15592985/BugslayerUtilG.zip
unzip BugslayerUtilG.zip -d content/System/
rm BugslayerUtilG.zip
- name: Update in Gothic 1 Steam workshop
if: startsWith(github.ref, 'refs/tags/')
uses: m00nl1ght-dev/steam-workshop-deploy@v2
with:
username: ${{ secrets.STEAM_USERNAME }}
configVdf: ${{ secrets.STEAM_CONFIG_VDF }}
path: content
appId: 65540
publishedFileId: 2786936496
changeNote: |
Version ${{ env.VERSION }}
https://github.com/szapp/Ninja/wiki/Changelog#${{ env.CHANGELOGID }}
- name: Update in Gothic 2 Steam workshop
if: startsWith(github.ref, 'refs/tags/')
uses: m00nl1ght-dev/steam-workshop-deploy@v2
with:
username: ${{ secrets.STEAM_USERNAME }}
configVdf: ${{ secrets.STEAM_CONFIG_VDF }}
path: content
appId: 39510
publishedFileId: 2786910489
changeNote: |
Version ${{ env.VERSION }}
https://github.com/szapp/Ninja/wiki/Changelog#${{ env.CHANGELOGID }}
cleanup:
runs-on: ubuntu-latest
needs: deploy
if: ${{ !cancelled() }}
permissions:
actions: write
steps:
- name: Clear cache
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete resources-${{ github.run_id }}-${{ github.run_attempt }} -R ${{ github.repository }} --confirm
gh actions-cache delete intermediate1-${{ github.run_id }}-${{ github.run_attempt }} -R ${{ github.repository }} --confirm
gh actions-cache delete intermediate2-${{ github.run_id }}-${{ github.run_attempt }} -R ${{ github.repository }} --confirm
gh actions-cache delete results-${{ github.run_id }}-${{ github.run_attempt }} -R ${{ github.repository }} --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}