360 lines (317 loc) 路 13.7 KB
/
windows-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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Please write our copyright if you use this file.
# 漏 2023 Floorp Projects & Contributors
#! SELF HOST DOES NOT SUPPORTED
#TODO: separate Publish to other workflow
#! aarch64 PGO can maybe not comportable with pgo
# name: Windows Build
# description: Action of Floorp Windows build (x64)
on:
workflow_call:
inputs:
profgen:
description: generate profile for PGO.
type: boolean
default: false
build32bit:
description: enable 32bit build
type: boolean
default: false
aarch64:
description: enable aarch64 build
type: boolean
default: false
zstd:
description: enable artifact as zstd fmt
type: boolean
default: false
beta:
type: boolean
default: false
#! does not compartible with aarch64
#? maybe light change needed to fix
mar:
type: boolean
default: false
#? if set this, use profdata, jarlog in build
profdata_jarlog_artifact_name:
description: profile artifact name;use profile for PGO;not compartible with profgen
type: string
default: ""
out_artifact_name:
type: string
default: ""
MOZ_BUILD_DATE:
type: string
default: ""
release-note-url:
type: string
required: false
default: ""
release-note-url-ja:
type: string
required: false
default: ""
outputs:
mar_name:
value: ${{jobs.win-build.outputs.mar_name}}
mar_size:
value: ${{jobs.win-build.outputs.mar_size}}
secrets:
PAT:
description: "Personal Access Token"
required: true
jobs:
win-build:
runs-on: ubuntu-latest
outputs:
mar_name: ${{steps.gen-mar.outputs.MAR_NAME}}
mar_size: ${{steps.gen-mar.outputs.MAR_SIZE}}
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Check Argument Compatibility
shell: node {0}
run: |
//profgen and use-profdata is not compatible
if (
process.env.GHA_profgen == "true"
&& process.env.GHA_profdata_jarlog_artifact_name != ""
) {process.exit(-1);}
//aarch64 and (profgen or profdata_jarlog_artifact_name) is not compatible
if (
process.env.GHA_aarch64 == "true"
&& (
process.env.GHA_profgen == "true"
|| process.env.GHA_profdata_jarlog_artifact_name != ""
)
) {process.exit(-1);}
// aarch64 & 32bit build is not compatible
if (
process.env.GHA_aarch64 == "true"
&& process.env.GHA_32bit == "true"
) {process.exit(-1);}
env:
GHA_profgen: ${{inputs.profgen}}
GHA_aarch64: ${{inputs.aarch64}}
GHA_32bit: ${{inputs.build32bit}}
GHA_zstd: ${{inputs.zstd}}
GHA_beta: ${{inputs.beta}}
GHA_mar: ${{inputs.mar}}
GHA_profdata_jarlog_artifact_name: ${{inputs.profdata_jarlog_artifact_name}}
GHA_out-artifact-name: ${{inputs.out_artifact_name}}
- name: Change PPA mirror servers
run: |
sudo perl -p -i -e 's%(deb(?:-src|)\s+)https?://(?!archive\.canonical\.com|security\.ubuntu\.com)[^\s]+%$1http://archive.ubuntu.com/ubuntu/%' /etc/apt/sources.list
sudo apt update
- uses: actions/checkout@v4
name: Clone 馃К
with:
submodules: 'recursive'
token: ${{ secrets.PAT }}
- name: Setup Disk & Swap Space 馃捒
run: |
chmod +x .github/workflows/src/disk_swap_for_github_runner.sh
.github/workflows/src/disk_swap_for_github_runner.sh
- name: Configure sccache
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- uses: actions/download-artifact@v4
name: Download artifact if use profdata馃摜
if: inputs.profdata_jarlog_artifact_name
with:
name: ${{inputs.profdata_jarlog_artifact_name}}
path: ~/artifact
- name: Setup 馃獩
run: |
mkdir -p ~/win-cross
if [[ $GHA_aarch64 == 'true' ]]; then
cp ./.github/workflows/src/windows/aarch64/mozconfig_win_aarch64_pgo_base mozconfig
elif [[ $GHA_32bit == 'true' ]]; then
cp ./.github/workflows/src/windows/x86/mozconfig_win_x86_pgo_base mozconfig
else
cp ./.github/workflows/src/windows/x86_64/mozconfig_win_x86_64_pgo_base mozconfig
fi
if [[ -n $GHA_MOZ_BUILD_DATE ]];then
export MOZ_BUILD_DATE=$GHA_MOZ_BUILD_DATE
fi
if [[ $GHA_beta == 'true' ]];then
echo 'ac_add_options --with-branding=browser/branding/beta' >> mozconfig
else
echo 'ac_add_options --with-branding=browser/branding/official' >> mozconfig
fi
echo 'ac_add_options --with-l10n-base=$PWD/floorp/browser/locales/l10n-central' >> mozconfig
if [[ $GHA_profgen == 'true' ]]; then
echo 'ac_add_options --enable-profile-generate=cross' >> mozconfig
elif [[ -n $GHA_profdata_jarlog_artifact_name ]]; then
echo 'ac_add_options --enable-profile-use=cross' >> mozconfig
echo 'ac_add_options --with-pgo-profile-path=$(echo ~)/artifact/merged.profdata' >> mozconfig
echo 'ac_add_options --with-pgo-jarlog=$(echo ~)/artifact/en-US.log' >> mozconfig
fi
# SCCACHE START
echo "mk_add_options 'export RUSTC_WRAPPER=/home/runner/.mozbuild/sccache/sccache'" >> mozconfig
echo "mk_add_options 'export CCACHE_CPP2=yes'" >> mozconfig
echo "ac_add_options --with-ccache=/home/runner/.mozbuild/sccache/sccache" >> mozconfig
echo "mk_add_options 'export SCCACHE_GHA_ENABLED=on'" >> mozconfig
# SCCACHE END
echo Setup wine
aria2c "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.cache.level-1.toolchains.v3.linux64-wine.latest/artifacts/public%2Fbuild%2Fwine.tar.zst" -o wine.tar.zst
tar --zstd -xvf wine.tar.zst -C ~/win-cross
rm wine.tar.zst
echo Setup Visual Studio
sudo apt install -y msitools python3-pip
./mach python --virtualenv build taskcluster/scripts/misc/get_vs.py build/vs/vs2019.yaml ~/win-cross/vs2019
chmod -R +x "$(echo ~)/win-cross/vs2019"
#? from daily-build-with-update
#? for resolve some problems relate to VCRuntime
#? from end
./mach --no-interactive bootstrap --application-choice browser
echo "export LIB=\"$(cd ~/.mozbuild/clang/lib/clang/* && cd lib/windows && pwd)\"" >> mozconfig
echo "DISPLAY_VERSION=$(cat ./browser/config/version_display.txt)" >> $GITHUB_ENV
echo "UPDATE_CHANNEL=release" >> $GITHUB_ENV
env:
GHA_profgen: ${{inputs.profgen}}
GHA_aarch64: ${{inputs.aarch64}}
GHA_32bit: ${{inputs.build32bit}}
GHA_beta: ${{inputs.beta}}
GHA_profdata_jarlog_artifact_name : ${{inputs.profdata_jarlog_artifact_name}}
GHA_MOZ_BUILD_DATE: ${{inputs.MOZ_BUILD_DATE}}
- name: setup Rust 馃
run: |
if [[ $GHA_aarch64 == 'true' ]];then
rustup target add aarch64-pc-windows-msvc
elif [[ $GHA_32bit == 'true' ]];then
rustup target add i686-pc-windows-msvc
else
rustup target add x86_64-pc-windows-msvc
fi
#? https://github.com/mozilla/sccache#known-caveats
export CARGO_INCREMENTAL=0
env:
GHA_aarch64: ${{inputs.aarch64}}
GHA_32bit: ${{inputs.build32bit}}
- name: Change update url if beta
if: inputs.beta
run: |
sed -i 's|https://@MOZ_APPUPDATE_HOST@/browser/%DISPLAY_VERSION%/%OS%/%ARCH%/update.xml|https://@MOZ_APPUPDATE_HOST@/browser/beta/%OS%/%ARCH%/update.xml |g' ./build/application.ini.in
#On Package, if not copies, error occur
- name: Copy l10n files if beta
if: inputs.beta
run: |
for dir in $(ls -l $PWD/floorp/browser/locales/l10n-central | grep ^d | awk '{print $9}'); do
mkdir -p $PWD/floorp/browser/locales/l10n-central/$dir/browser/branding/beta
cp ./browser/branding/beta/locales/en-US/brand.dtd $PWD/floorp/browser/locales/l10n-central/$dir/browser/branding/beta/brand.dtd
cp ./browser/branding/beta/locales/en-US/brand.ftl $PWD/floorp/browser/locales/l10n-central/$dir/browser/branding/beta/brand.ftl
cp ./browser/branding/beta/locales/en-US/brand.properties $PWD/floorp/browser/locales/l10n-central/$dir/browser/branding/beta/brand.properties
done
- name: Change Release Note for Japanese
if: inputs.release-note-url-ja
run: |
sed -i 's|https://blog.ablaze.one/category/ablaze/ablaze-project/floorp/#ja|${{inputs.release-note-url-ja}}|g' ./browser/branding/official/pref/firefox-branding.js
echo "$(cat ./browser/branding/official/pref/firefox-branding.js)"
- name: Change Release Note URL
if: inputs.release-note-url
run: |
sed -i 's|https://blog.ablaze.one/category/ablaze/ablaze-project/floorp/|${{inputs.release-note-url}}|g' ./browser/branding/official/pref/firefox-branding.js
echo "$(cat ./browser/branding/official/pref/firefox-branding.js)"
- name: Build 馃敤
continue-on-error: true
run: |
if [[ -n $GHA_MOZ_BUILD_DATE ]];then
export MOZ_BUILD_DATE=$GHA_MOZ_BUILD_DATE
fi
./mach build
env:
GHA_MOZ_BUILD_DATE: ${{inputs.MOZ_BUILD_DATE}}
- name: Retry Build if 1st build is failed 馃敤
if: failure()
run: |
if [[ -n $GHA_MOZ_BUILD_DATE ]];then
export MOZ_BUILD_DATE=$GHA_MOZ_BUILD_DATE
fi
./mach build
env:
GHA_MOZ_BUILD_DATE: ${{inputs.MOZ_BUILD_DATE}}
- name: Package 馃摝
run: |
if [[ -n $GHA_MOZ_BUILD_DATE ]];then
export MOZ_BUILD_DATE=$GHA_MOZ_BUILD_DATE
fi
./mach package
./mach package-multi-locale --locales ar cs da de el en-US en-GB es-ES fr hu id it ja ko lt nl nn-NO pl pt-BR pt-PT ru sv-SE th tr uk vi zh-CN zh-TW
env:
GHA_MOZ_BUILD_DATE: ${{inputs.MOZ_BUILD_DATE}}
- name: Copy 馃搨
run: |
mkdir ~/output
if [[ $GHA_aarch64 == 'true' ]];then
arch="aarch64"
arch_inst="win64-aarch64"
elif [[ $GHA_32bit == 'true' ]];then
arch="i686"
arch_inst="win32"
else
arch="x86_64"
arch_inst="win64"
fi
if [[ $GHA_zstd != 'true' ]];then
cp obj-${arch}-pc-windows-msvc/dist/install/sea/floorp-*.en-US.${arch_inst}.installer-stub.exe ~/output/floorp-stub.installer.exe
cp obj-${arch}-pc-windows-msvc/dist/floorp-*.en-US.${arch_inst}.zip ~/output/
cp obj-${arch}-pc-windows-msvc/dist/install/sea/floorp-*.en-US.${arch_inst}.installer.exe ~/output/floorp-${arch_inst}.installer.exe
else
cp obj-${arch}-pc-windows-msvc/dist/floorp-*.en-US.${arch_inst}.zip ~/output/
7z x ~/output/floorp-*.en-US.${arch_inst}.zip
tar -I "zstd -T4 -10" --remove-files -cvf ~/output/floorp-$(cat browser/config/version.txt).en-us.${arch_inst}.tar.zst floorp
rm ~/output/floorp-*.en-US.${arch_inst}.zip
fi
#? Original code used in daily b with update
# cp -r obj-x86_64-pc-mingw32/dist/floorp ~/output/
env:
GHA_aarch64: ${{inputs.aarch64}}
GHA_32bit: ${{inputs.build32bit}}
GHA_zstd: ${{inputs.zstd}}
GHA_beta: ${{inputs.beta}}
- name: Create MAR artifact 馃摝
id: gen-mar
if : inputs.mar
run: |
if [[ $GHA_aarch64 == 'true' ]];then
arch="aarch64"
elif [[ $GHA_32bit == 'true' ]];then
arch="i686"
else
arch="x86_64"
fi
touch "obj-${arch}-pc-windows-msvc/dist/floorp/precomplete"
MAR="obj-${arch}-pc-windows-msvc/dist/host/bin/mar" \
MOZ_PRODUCT_VERSION=$(cat browser/config/version_display.txt) \
MAR_CHANNEL_ID=release \
./tools/update-packaging/make_full_update.sh ~/output "obj-${arch}-pc-windows-msvc/dist/floorp"
mv ~/output/*.mar ~/output/WINNT-${arch}.mar
echo "MAR_NAME=WINNT-${arch}.mar" >> $GITHUB_OUTPUT
echo "MAR_SIZE=$(stat -c "%s" ~/output/WINNT-${arch}.mar)" >> $GITHUB_OUTPUT
env:
GHA_32bit: ${{inputs.build32bit}}
# Publish START
- name: make name of publish archive
shell: node {0}
run: |
const fs = require('fs');
let name = process.env.GHA_out_artifact_name ? process.env.GHA_out_artifact_name : process.env.GHA_default_name
fs.appendFileSync(process.env.GITHUB_ENV, `ARTIFACT_NAME=${name}`);
env:
GHA_out_artifact_name : ${{inputs.out_artifact_name}}
GHA_default_name: floorp-windows-${{fromJson('["x86","aarch"]')[inputs.aarch64]}}${{fromJson('["_64",""]')[inputs.build32bit]}}-${{fromJson('["package","build-with-profgen"]')[inputs.profgen]}}${{fromJson('["","-zstd"]')[inputs.zstd]}}
- name: Publish Package馃巵
uses: actions/upload-artifact@v4
with:
name: ${{env.ARTIFACT_NAME}}
path: ~/output
# Publish END