name: macOS Release Build permissions: contents: read on: workflow_call: inputs: generate-pgo: required: true type: boolean default: false disable-pgo: description: "Build without PGO at all" required: false type: boolean default: false build-version: description: "The version to build" required: true type: string release-branch: description: "The branch to build" required: true type: string MOZ_BUILD_DATE: type: string required: true default: "" use-sccache: description: "Use sccache" required: true type: boolean default: false jobs: mac-build: name: Build macOS - ${{ matrix.arch }} runs-on: 'blacksmith-8vcpu-ubuntu-2404' env: SCCACHE_GHA_ENABLED: ${{ inputs.use-sccache && 'true' || 'false' }} CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 strategy: fail-fast: false matrix: arch: [x86_64, aarch64] steps: - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main with: tool-cache: false - name: Checkout repository uses: actions/checkout@v4 with: submodules: recursive token: ${{ secrets.DEPLOY_KEY }} - name: Setup Node.js uses: useblacksmith/setup-node@v5 with: node-version-file: ".nvmrc" - name: Run sccache-cache uses: mozilla-actions/sccache-action@main if: ${{ inputs.use-sccache }} with: disable_annotations: true - name: Expose actions cache variables uses: actions/github-script@v6 with: script: | core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL']) core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']) - name: Setup Git run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - name: Install dependencies run: | npm ci sudo apt-get update sudo apt-get install -y python3 python3-pip zstd yasm nasm build-essential libgtk2.0-dev libpython3-dev m4 uuid libasound2-dev libcurl4-openssl-dev libdbus-1-dev libdrm-dev libdbus-glib-1-dev libgtk-3-dev libpulse-dev libx11-xcb-dev libxt-dev xvfb --fix-missing - name: Load Surfer CI setup run: npm run surfer -- ci --brand ${{ inputs.release-branch }} --display-version ${{ inputs.build-version }} - name: Download Firefox and dependencies run: npm run download - name: mac-cross Cache env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 id: cache-mac-cross uses: useblacksmith/cache@v5 with: path: ${HOME}/mac-cross key: mac-cross - name: Setup for macOS (cctools and DMG tools) if: steps.cache-mac-cross.outputs.cache-hit != 'true' run: | set -ex mkdir -p ~/mac-cross cd engine/ ./mach artifact toolchain --from-build linux64-cctools-port linux64-libdmg linux64-hfsplus mv cctools dmg hfsplus ~/mac-cross/ ls ~/mac-cross/cctools/bin/x86_64-apple-darwin-ld ~/mac-cross/cctools/bin/aarch64-apple-darwin-ld ~/mac-cross/dmg/dmg ~/mac-cross/hfsplus/newfs_hfs - name: Setup Rust run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(cat .rust-toolchain) source $HOME/.cargo/env if test "${{ matrix.arch }}" = "aarch64"; then rustup target add aarch64-apple-darwin else rustup target add x86_64-apple-darwin fi - name: Import env: SURFER_COMPAT: ${{ matrix.arch }} SURFER_CERT_PATCH_ISSUER: ${{ secrets.SURFER_CERT_PATCH_ISSUER }} SURFER_CERT_PATCH_NAME: ${{ secrets.SURFER_CERT_PATCH_NAME }} SURFER_CERT_PATCH_NAME_PREV: ${{ secrets.SURFER_CERT_PATCH_NAME_PREV }} SURFER_CERT_PATCH_ISSUER_PREV: ${{ secrets.SURFER_CERT_PATCH_ISSUER_PREV }} SURFER_PLATFORM: darwin run: | . "$HOME/.cargo/env" npm run import -- --verbose - name: Bootstrap run: | set -x export SURFER_PLATFORM="darwin" npm run bootstrap - name: Build language packs run: sh scripts/download-language-packs.sh - name: Download artifact (if use profdata) uses: actions/download-artifact@v4 if: ${{ !inputs.generate-pgo && !inputs.disable-pgo }} with: path: ~/artifact name: macos-profdata-${{ matrix.arch }} - name: Show artifact info if: ${{ !inputs.generate-pgo && !inputs.disable-pgo }} run: | ls ~/artifact ls ~/artifact/en-US.log ls ~/artifact/merged.profdata - name: Build env: SURFER_COMPAT: ${{ matrix.arch }} ZEN_RELEASE_BRANCH: ${{ inputs.release-branch }} ZEN_SAFEBROWSING_API_KEY: ${{ secrets.ZEN_SAFEBROWSING_API_KEY }} ZEN_MOZILLA_API_KEY: ${{ secrets.ZEN_MOZILLA_API_KEY }} ZEN_GOOGLE_LOCATION_SERVICE_API_KEY: ${{ secrets.ZEN_GOOGLE_LOCATION_SERVICE_API_KEY }} run: | set -x export SURFER_PLATFORM="darwin" export ZEN_CROSS_COMPILING=1 if test ${{ inputs.generate-pgo }} = true; then export ZEN_GA_GENERATE_PROFILE=1 fi if test ${{ inputs.disable-pgo }} = true; then export ZEN_GA_DISABLE_PGO=1 fi if [[ -n ${{ inputs.MOZ_BUILD_DATE }} ]];then export MOZ_BUILD_DATE=${{ inputs.MOZ_BUILD_DATE }} fi bash .github/workflows/src/release-build.sh - name: Package instrumented app (PGO stage 1) if: ${{ inputs.generate-pgo }} env: SURFER_COMPAT: ${{ matrix.arch }} ZEN_RELEASE: 1 SURFER_PLATFORM: darwin ZEN_CROSS_COMPILING: 1 ZEN_GA_GENERATE_PROFILE: 1 run: | set -ex cd engine ./mach package mv obj-${{ matrix.arch }}-apple-darwin/dist/*.dmg "$GITHUB_WORKSPACE/zen-macos-pgo-stage1-${{ matrix.arch }}.dmg" - name: Upload artifact (PGO stage 1) uses: actions/upload-artifact@v4 if: ${{ inputs.generate-pgo }} with: retention-days: 2 name: macos-pgo-stage1-${{ matrix.arch }} path: ./zen-macos-pgo-stage1-${{ matrix.arch }}.dmg - name: Package if: ${{ !inputs.generate-pgo }} env: SURFER_COMPAT: ${{ matrix.arch }} ZEN_GA_DISABLE_PGO: true run: | set -x export SURFER_PLATFORM="darwin" export ZEN_CROSS_COMPILING=1 export ZEN_RELEASE=1 npm run package - name: Rename artifacts if: ${{ !inputs.generate-pgo }} run: | set -ex mv ./dist/*.dmg ./zen-${{ matrix.arch }}-apple-darwin-dist.dmg mv ./engine/obj-${{ matrix.arch }}-apple-darwin/dist/bin/platform.ini ./platform.ini - name: Upload dist dmg uses: actions/upload-artifact@v4 if: ${{ !inputs.generate-pgo }} with: retention-days: 1 name: zen-${{ matrix.arch }}-apple-darwin-dist.dmg path: ./zen-${{ matrix.arch }}-apple-darwin-dist.dmg - name: Upload platform.ini uses: actions/upload-artifact@v4 if: ${{ !inputs.generate-pgo && matrix.arch == 'x86_64' }} with: retention-days: 1 name: platform.ini path: ./platform.ini