forked from 1dot13/source
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (182 loc) · 6.58 KB
/
build_language.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
name: build language
on:
workflow_call:
inputs:
language:
description: 'any of Chinese German English French Polish Italian Dutch Russian'
required: true
default: 'English'
type: string
assemble:
description: 'assemble full package'
required: true
default: true
type: boolean
continue-on-error:
description: 'allows a language to fail, used when building all languages'
required: false
default: false
type: boolean
jobs:
compile:
runs-on: windows-latest # required for msbuild
continue-on-error: ${{ inputs.continue-on-error }}
strategy:
fail-fast: false
matrix:
application: [ja2, ja2mapeditor, ja2ub, ja2ubmapeditor]
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Download versions.env
uses: actions/download-artifact@v4
with:
name: versions.env
path: artifacts
- name: Restore versions.env
shell: bash
run: cat artifacts/versions.env >> $GITHUB_ENV
# TODO: Move this into CMake, just taking the GitHub Actions parameters as -D variables
- name: Update GameVersion.cpp
shell: bash
run: |
set -eux
INPUTS_LANGUAGE=${{ inputs.language }}
GAME_VERSION=$(echo "$GAME_VERSION" | tr -cd '[:print:]' | tr -d '"\\')
GAME_BUILD="${INPUTS_LANGUAGE:0:2} $GAME_BUILD_INFORMATION"
GAME_BUILD=$(echo "$GAME_BUILD" | tr -cd '[:print:]' | tr -d '"\\')
sed -i "s|@Version@|${GAME_VERSION:0:15}|" Ja2/GameVersion.cpp
sed -i "s|@Build@|${GAME_BUILD:0:255}|" Ja2/GameVersion.cpp
cat Ja2/GameVersion.cpp
- name: Prepare build properties
shell: bash
run: |
set -eux
touch CMakePresets.json
JA2Language=$(echo '${{ inputs.language }}' | tr '[:lower:]' '[:upper:]')
JA2Application=$(echo '${{ matrix.application }}' | tr '[:lower:]' '[:upper:]')
LTO=${{ inputs.assemble }}
echo "
JA2Language=$JA2Language
JA2Application=$JA2Application
LTO=$LTO
" >> $GITHUB_ENV
- uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x86
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86
- name: Prepare build
run: |
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DLanguages="$Env:JA2Language" -DApplications="$Env:JA2Application" -DLTO_OPTION="$Env:LTO"
- name: Build
run: |
cmake --build build/ -- -v
- name: List build artifacts
shell: bash
run: |
find build/
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.language }}_${{ matrix.application }}
path: build/*.exe
assemble:
needs: [ compile ]
if: inputs.assemble
runs-on: windows-latest # required for case-insensitive filesystem handling
continue-on-error: ${{ inputs.continue-on-error }}
steps:
- name: Download versions.env
uses: actions/download-artifact@v4
with:
name: versions.env
path: artifacts
- name: Restore versions.env
shell: bash
run: cat artifacts/versions.env >> $GITHUB_ENV
- name: Checkout gamedir
uses: actions/checkout@v4
with:
repository: ${{ env.GAMEDIR_REPOSITORY }}
ref: ${{ env.GAMEDIR_COMMIT_SHA }}
path: gamedir
- name: Checkout gamedir-languages
if: inputs.language != 'English'
uses: actions/checkout@v4
with:
repository: ${{ env.GAMEDIR_LANGUAGES_REPOSITORY }}
ref: ${{ env.GAMEDIR_LANGUAGES_COMMIT_SHA }}
path: gamedir-languages
- name: Copy gamedir-languages files to gamedir
if: inputs.language != 'English'
shell: bash
run: |
set -eux
cp -a gamedir-languages/${{ inputs.language }}_Version/* gamedir/
- name: Download ja2
uses: actions/download-artifact@v4
with:
name: ${{ inputs.language }}_ja2
path: artifacts/ja2
- name: Download ja2mapeditor
uses: actions/download-artifact@v4
with:
name: ${{ inputs.language }}_ja2mapeditor
path: artifacts/ja2mapeditor
- name: Download ja2ub
uses: actions/download-artifact@v4
with:
name: ${{ inputs.language }}_ja2ub
path: artifacts/ja2ub
- name: Download ja2ubmapeditor
uses: actions/download-artifact@v4
with:
name: ${{ inputs.language }}_ja2ubmapeditor
path: artifacts/ja2ubmapeditor
- name: Copy application files to gamedir
shell: bash
run: |
set -eux
for APP in ja2 ja2mapeditor ja2ub ja2ubmapeditor
do
mv artifacts/${APP}/*.exe gamedir/${APP}.exe
done
- name: Create version information file
shell: bash
run: |
set -eux
# "-" separates words, "_" combines words, see double-click behavior
DIST_PREFIX='JA2_113'
DIST_NAME="${DIST_PREFIX}-${GAME_VERSION}-G${GAMEDIR_COMMIT_SHA:0:4}L${GAMEDIR_LANGUAGES_COMMIT_SHA:0:4}-${{ inputs.language }}"
echo "DIST_NAME=$DIST_NAME" >> $GITHUB_ENV
echo "If you encounter problems during gameplay, please provide the following version information:
Distribution Name: $DIST_NAME
Game Version: $GAME_VERSION
Language: ${{ inputs.language }}
Build Information: $GAME_BUILD_INFORMATION
Source Repository: $GITHUB_REPOSITORY
Source Commit SHA: $GITHUB_SHA
Source Commit Date: $SOURCE_COMMIT_DATETIME
Gamedir Repository: $GAMEDIR_REPOSITORY
Gamedir Commit SHA: $GAMEDIR_COMMIT_SHA
Gamedir Commit Date: $GAMEDIR_COMMIT_DATETIME
Gamedir Languages Repository: $GAMEDIR_LANGUAGES_REPOSITORY
Gamedir Languages Commit SHA: $GAMEDIR_LANGUAGES_COMMIT_SHA
Gamedir Languages Commit Date: $GAMEDIR_LANGUAGES_COMMIT_DATETIME
" > "gamedir/${DIST_PREFIX}-Version.txt"
cat "gamedir/${DIST_PREFIX}-Version.txt"
- name: Create release archive
shell: bash
run: |
set -eux
mkdir dist/
cd gamedir/
7z a -bb -xr'!.*' "../dist/${DIST_NAME}.7z" .
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.language }}_release
path: dist/
compression-level: 0