feat: implement Tab Service v2 and replace old tab manager #708
This file contains hidden or 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
| name: Build App | |
| permissions: {} | |
| on: | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Run on every push to a pull request | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| # Cancel in-progress jobs when a new push is made to the same PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Runs before the build starts | |
| # Cannot find a way to do this yet without compromising security | |
| before-build-comment: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Comment PR with build status | |
| if: github.event_name == 'pull_request' | |
| continue-on-error: true | |
| uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 | |
| with: | |
| message: | | |
| ### Build is in progress... 🚀 | |
| Currently building for this pull request! | |
| comment-tag: build | |
| # Flatpak using manifest + generated-sources from Flathub (cloned each run to stay in sync) | |
| build-flatpak: | |
| needs: before-build-comment | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| flatpak_arch: x86_64 | |
| - os: ubuntu-24.04-arm | |
| flatpak_arch: aarch64 | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - name: Clone Flathub packaging (com.flow_browser.flow) | |
| run: git clone --depth 1 -b master https://github.com/flathub/com.flow_browser.flow.git flatpak-upstream | |
| - name: Stage app sources for Flatpak build | |
| run: | | |
| mkdir -p flatpak-upstream/main | |
| rsync -a --delete \ | |
| --exclude='.git/' \ | |
| --exclude='node_modules/' \ | |
| --exclude='dist/' \ | |
| --exclude='out/' \ | |
| --exclude='flatpak-upstream/' \ | |
| ./ flatpak-upstream/main/ | |
| - name: Set Flatpak metainfo version (package version + short SHA) | |
| run: | | |
| python3 <<'PY' | |
| import json | |
| import os | |
| import re | |
| from datetime import datetime, timezone | |
| from pathlib import Path | |
| sha = os.environ["GITHUB_SHA"] | |
| short = sha[:7] | |
| root = Path("flatpak-upstream/main") | |
| pkg = json.loads((root / "package.json").read_text()) | |
| base = str(pkg["version"]).split("+", 1)[0] | |
| version = f"{base}+{short}" | |
| meta_path = root / "com.flow_browser.flow.metainfo.xml" | |
| text = meta_path.read_text() | |
| today = datetime.now(timezone.utc).strftime("%Y-%m-%d") | |
| text, n = re.subn( | |
| r'(<release version=")[^"]+(" date=")[^"]+(")', | |
| rf"\g<1>{version}\g<2>{today}\g<3>", | |
| text, | |
| count=1, | |
| ) | |
| if n != 1: | |
| raise SystemExit( | |
| "Expected exactly one <release> in com.flow_browser.flow.metainfo.xml; " | |
| "update the regex in build.yml if the file changed." | |
| ) | |
| meta_path.write_text(text) | |
| PY | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: 1.3.10 | |
| - name: Generate Flatpak sources from local bun.lock | |
| working-directory: flatpak-upstream | |
| run: | | |
| rm -f ./generated-sources.json | |
| bun add -g flatpak-bun-generator@latest | |
| SCRIPT_PATH="$(readlink -f "$(bun pm bin -g)/flatpak-bun-generator")" | |
| node "$SCRIPT_PATH" ./main/bun.lock --output ./generated-sources.json | |
| - name: Patch Flathub manifest to build from this checkout | |
| run: | | |
| python3 <<'PY' | |
| import re | |
| from pathlib import Path | |
| path = Path("flatpak-upstream/com.flow_browser.flow.yml") | |
| text = path.read_text() | |
| pattern = r" - type: archive\n(?:(?! - generated-sources).)+\n is-main-source: true\n" | |
| replacement = ( | |
| " - type: dir\n" | |
| " path: main\n" | |
| " dest: main\n" | |
| ) | |
| new_text, n = re.subn(pattern, replacement, text, count=1, flags=re.DOTALL) | |
| if n != 1: | |
| raise SystemExit( | |
| "Expected to replace exactly one Flathub main source archive block; " | |
| "update the regex in build.yml if com.flow_browser.flow.yml changed." | |
| ) | |
| path.write_text(new_text) | |
| PY | |
| - name: Install Flatpak tooling | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y flatpak flatpak-builder | |
| - name: Setup Flathub remote | |
| run: flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo | |
| # Single online build: a second phase with --disable-download runs the sandbox without | |
| # outbound network, but bun still resolves optional/native deps (e.g. rolldown/lightningcss | |
| # bindings) that flatpak-bun-generator may not fully vendor — bun install then fails. | |
| - name: Build Flatpak | |
| working-directory: flatpak-upstream | |
| run: | | |
| flatpak-builder --user --install-deps-from=flathub --repo="${{ github.workspace }}/flatpak-repo" \ | |
| --force-clean build-dir com.flow_browser.flow.yml | |
| - name: Create Flatpak bundle | |
| run: | | |
| mkdir -p dist-flatpak | |
| flatpak build-bundle --arch=${{ matrix.flatpak_arch }} \ | |
| "${{ github.workspace }}/flatpak-repo" \ | |
| "dist-flatpak/com.flow_browser.flow.${{ matrix.flatpak_arch }}.flatpak" \ | |
| com.flow_browser.flow | |
| - name: Upload Flatpak bundle | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: flatpak-${{ matrix.os }} | |
| path: dist-flatpak/*.flatpak | |
| # Runs the build | |
| build: | |
| needs: before-build-comment | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel, windows-latest] | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - name: Install Node.js, NPM and Yarn | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 22 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: 1.3.10 | |
| - name: Use Stock Electron (Ubuntu ARM only) | |
| if: matrix.os == 'ubuntu-24.04-arm' | |
| run: bun run script:use-stock-electron | |
| - name: Install Build Dependencies (Ubuntu only) | |
| if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y flatpak-builder elfutils dpkg fakeroot | |
| - name: Install Additional Build Dependencies (Ubuntu ARM only) | |
| if: matrix.os == 'ubuntu-24.04-arm' | |
| run: | | |
| sudo apt-get install -y ruby ruby-dev | |
| sudo gem install --no-document fpm -v 1.17.0 | |
| - name: Setup Flatpak (Ubuntu only) | |
| if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' | |
| run: | | |
| flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo | |
| - name: Install Dependencies | |
| run: bun install --development --frozen-lockfile | |
| env: | |
| SHARP_IGNORE_GLOBAL_LIBVIPS: 1 | |
| - name: Build for Linux | |
| if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' | |
| run: bun run build:linux -p never | |
| env: | |
| USE_SYSTEM_FPM: ${{ matrix.os == 'ubuntu-24.04-arm' }} | |
| - name: Build for macOS | |
| if: matrix.os == 'macos-latest' || matrix.os == 'macos-15-intel' | |
| run: bun run build:mac -p never | |
| - name: Build for Windows | |
| if: matrix.os == 'windows-latest' | |
| run: bun run build:win -p never | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: ${{ matrix.os }} | |
| path: | | |
| dist/*.exe | |
| dist/*.zip | |
| dist/*.dmg | |
| dist/*.AppImage | |
| dist/*.deb | |
| dist/*.rpm | |
| dist/*.tar.gz | |
| dist/*.yml | |
| dist/*.blockmap | |
| dist/*.flatpak | |
| # Runs after all builds complete | |
| after-build-comment: | |
| needs: [build, build-flatpak] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| env: | |
| BUILD_ARTIFACTS_MESSAGE: | | |
| ### Build artifacts for all platforms are ready! 🚀 | |
| Download the artifacts for: | |
| - [Linux](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ubuntu-latest.zip) | |
| - [Linux (arm64)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ubuntu-24.04-arm.zip) | |
| - [macOS](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/macos-latest.zip) | |
| - [macOS (Intel)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/macos-15-intel.zip) | |
| - [Windows](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/windows-latest.zip) | |
| - [Flatpak (x64)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/flatpak-ubuntu-latest.zip) | |
| - [Flatpak (arm64)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/flatpak-ubuntu-24.04-arm.zip) | |
| <details> | |
| <summary>One-line installer (Unstable):</summary> | |
| ```bash | |
| bunx flow-debug-build@1.2.1 --open ${{ github.run_id }} | |
| ``` | |
| </details> | |
| _(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_ | |
| steps: | |
| - name: Add workflow summary | |
| run: printf '%s\n' "$BUILD_ARTIFACTS_MESSAGE" >> "$GITHUB_STEP_SUMMARY" | |
| - name: Comment PR with artifact links | |
| if: github.event_name == 'pull_request' | |
| uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 | |
| continue-on-error: true | |
| with: | |
| message: ${{ env.BUILD_ARTIFACTS_MESSAGE }} | |
| comment-tag: build |