-
-
Notifications
You must be signed in to change notification settings - Fork 174
302 lines (260 loc) · 10.6 KB
/
macOS-Universal.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
# 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
name: "(A) ⚒ macOS Universal Build"
on:
workflow_call:
inputs:
profgen:
description: generate profile for PGO.
type: boolean
default: false
beta:
type: boolean
default: false
#? if set this, use profdata, jarlog in build
build-with-profdata-and-jarlog:
description: build with profdata and jarlog
type: boolean
default: false
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: ""
secrets:
MACOS_CROSS_TOOLS_KEY:
description: macOS cross tools 7z password
required: true
PAT:
description: "Personal Access Token"
required: true
workflow_dispatch:
inputs:
profgen:
description: generate profile for PGO.
type: boolean
default: false
#? if set this, use profdata, jarlog in build
build-with-profdata-and-jarlog:
description: build with profdata and jarlog
type: boolean
default: false
out_artifact_name:
type: string
default: ""
MOZ_BUILD_DATE:
type: string
default: ""
jobs:
mac-build:
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
runs-on: ["ubuntu-latest"]
arch: [x86_64, aarch64]
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Check Argument Compatibility
shell: node {0}
run: |
if (
process.env.GHA_profgen == "true"
&& process.env.GHA_profdata_jarlog_artifact_name == "true"
) {process.exit(-1); console.log("profgen and use-profdata is not compatible")}
env:
GHA_profgen: ${{inputs.profgen}}
GHA_profdata_jarlog_artifact_name: ${{inputs.build-with-profdata-and-jarlog}}
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
echo "$GHA_aarch64"
- 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.build-with-profdata-and-jarlog
with:
name: floorp-${{ matrix.arch }}-apple-darwin-profdata-and-jarlog
path: ~/artifact
- name: Setup Cross Build tools 🪛
run: |
wget -P /home/runner/cross-tools/ https://repo.ablaze.one/data/floorp/macos-cross-tools/macOS-cross-tools.7z
7z x -y -p${{ secrets.MACOS_CROSS_TOOLS_KEY }} /home/runner/cross-tools/macOS-cross-tools.7z -o/home/runner/cross-tools/
## TODO: move mozconfig_darwin_pgo_base to src/macOS
- name: Create config for "${{ matrix.arch }}" 📦
run: |
sudo apt update
sudo apt upgrade -y
cp ./.github/workflows/src/mac/shared/mozconfig_darwin_pgo_base mozconfig
if [[ $GHA_ARCH == 'x86_64' ]];then
cat ./.github/workflows/src/mac/x86_64/x86_64-optimize-base >> mozconfig
else
cat ./.github/workflows/src/mac/aarch64/aarch64-optimize-base >> mozconfig
fi
echo 'mozconfig: **********************'
cat ./mozconfig
echo '*********************************'
./mach --no-interactive bootstrap --application-choice browser
sudo apt install -y p7zip-full zip tar
env:
GHA_ARCH: ${{matrix.arch}}
- name: Bootstrap 🥾
run: |
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
if [[ $GHA_profgen == 'true' ]]; then
echo 'ac_add_options --enable-profile-generate=cross' >> mozconfig
elif [[ $GHA_profdata_jarlog_artifact_name == 'true' ]]; 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
./mach --no-interactive bootstrap --application-choice browser
echo "DISPLAY_VERSION=$(cat ./browser/config/version_display.txt)" >> $GITHUB_ENV
echo "UPDATE_CHANNEL=release" >> $GITHUB_ENV
env:
GHA_profgen: ${{inputs.profgen}}
GHA_profdata_jarlog_artifact_name : ${{inputs.build-with-profdata-and-jarlog}}
GHA_MOZ_BUILD_DATE: ${{inputs.MOZ_BUILD_DATE}}
GHA_beta: ${{inputs.beta}}
- name: setup Rust 🦀
run: |
rustup toolchain install 1.81.0
rustup default 1.81.0
if [[ $GHA_ARCH == 'x86_64' ]];then
rustup target add x86_64-apple-darwin --toolchain 1.81.0
else
rustup target add aarch64-apple-darwin --toolchain 1.81.0
fi
#? https://github.com/mozilla/sccache#known-caveats
export CARGO_INCREMENTAL=0
env:
GHA_ARCH: ${{matrix.arch}}
- 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 🔨
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-JP-mac 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 & Compress Artifacts 📁
run: |
mkdir ~/output
if [[ $GHA_ARCH == 'aarch64' ]];then
arch="aarch64"
else
arch="x86_64"
fi
if [[ $GHA_profgen = 'true' ]];then
tar zcvf ${arch}-apple-darwin-output.tar.xz ./obj-${arch}-apple-darwin/dist/floorp
mv ${arch}-apple-darwin-output.tar.xz ~/output/
else
tar -czf floorp-${arch}-apple-darwin-with-pgo.tar.gz ./obj-${arch}-apple-darwin/dist/
mv floorp-${arch}-apple-darwin-with-pgo.tar.gz ~/output/
fi
env:
GHA_profgen: ${{inputs.profgen}}
GHA_ARCH: ${{matrix.arch}}
# 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-mac-${{ matrix.arch }}-${{fromJson('["package","build-with-profgen"]')[inputs.profgen]}}
- name: Publish Package🎁
uses: actions/upload-artifact@v4
with:
name: ${{env.ARTIFACT_NAME}}
path: ~/output
# Publish END