Floorp-Projects/Floorp - Windows ARM64 build #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 Midori Projects & Contributors | |
permissions: write-all | |
name: "Build Browser" | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
type: string | |
description: browser name | |
required: true | |
repo: | |
type: string | |
description: repo url | |
required: true | |
branch: | |
type: string | |
description: repo branch | |
required: true | |
workflow_call: | |
inputs: | |
profgen: | |
description: generate profile for PGO. | |
type: boolean | |
default: false | |
aarch64: | |
description: enable aarch64 build | |
type: boolean | |
default: true | |
zstd: | |
description: enable artifact as zstd fmt | |
type: boolean | |
default: false | |
beta: | |
type: boolean | |
default: false | |
mar: | |
type: boolean | |
default: false | |
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}} | |
run-name: "${{inputs.repo}} - Windows ARM64 build" | |
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: 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' | |
repository: ${{inputs.repo}} | |
ref: ${{inputs.branch}} | |
- 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 | |
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/vs2022.yaml ~/win-cross/vs2022 | |
chmod -R +x "$(echo ~)/win-cross/vs2022" | |
#? 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_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 --toolchain stable | |
else | |
rustup target add x86_64-pc-windows-msvc --toolchain stable | |
fi | |
#? https://github.com/mozilla/sccache#known-caveats | |
export CARGO_INCREMENTAL=0 | |
env: | |
GHA_aarch64: ${{inputs.aarch64}} | |
- 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: 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 build | |
./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" | |
else | |
arch="x86_64" | |
arch_inst="win64" | |
fi | |
if [[ $GHA_zstd != 'true' ]];then | |
cp obj-${arch}-pc-windows-msvc/dist/install/sea/${{inputs.name}}-*.en-US.${arch_inst}.installer-stub.exe ~/output/midori-stub.installer.exe | |
cp obj-${arch}-pc-windows-msvc/dist/${{inputs.name}}-*.en-US.${arch_inst}.zip ~/output/ | |
cp obj-${arch}-pc-windows-msvc/dist/install/sea/${{inputs.name}}-*.en-US.${arch_inst}.installer.exe ~/output/midori-${arch_inst}.installer.exe | |
else | |
cp obj-${arch}-pc-windows-msvc/dist/${{inputs.name}}-*.en-US.${arch_inst}.zip ~/output/ | |
7z x ~/output/${{inputs.name}}-*.en-US.${arch_inst}.zip | |
tar -I "zstd -T4 -10" --remove-files -cvf ~/output/${{inputs.name}}-$(cat browser/config/version.txt).en-us.${arch_inst}.tar.zst midori | |
rm ~/output/${{inputs.name}}-*.en-US.${arch_inst}.zip | |
fi | |
#? Original code used in daily b with update | |
# cp -r obj-x86_64-pc-mingw32/dist/${{inputs.name}} ~/output/ | |
env: | |
GHA_aarch64: ${{inputs.aarch64}} | |
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" | |
else | |
arch="x86_64" | |
fi | |
touch "obj-${arch}-pc-windows-msvc/dist/midori/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/midori" | |
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 | |
# 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: ${{inputs.name}}-windows-${{fromJson('["x86","aarch"]')[inputs.aarch64]}}-${{fromJson('["package","build-with-profgen"]')[inputs.profgen]}}${{fromJson('["","-zstd"]')[inputs.zstd]}} | |
- name: Create Release | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: '${{ secrets.GITHUB_TOKEN }}' | |
automatic_release_tag: '${{inputs.name}}-${{inputs.branch}}' | |
prerelease: true | |
title: '${{inputs.repo}} ${{inputs.branch}}' | |
files: ${{env.ARTIFACT_NAME}} | |
# Publish END |