Files
swiftcontrol/.github/workflows/patch.yml
Jonas Acker 20a84df08e Add Linux to the Shorebird patch workflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 09:43:03 +01:00

369 lines
16 KiB
YAML

name: "Patch"
on:
workflow_dispatch:
inputs:
build_mac:
description: 'Patch for macOS'
required: false
default: true
type: boolean
build_windows:
description: 'Patch for Windows'
required: false
default: true
type: boolean
build_android:
description: 'Patch for Android'
required: false
default: true
type: boolean
build_ios:
description: 'Patch for iOS'
required: false
default: true
type: boolean
build_linux:
description: 'Patch for Linux (x64; arm64 is not a Shorebird release)'
required: false
default: true
type: boolean
release_version:
description: 'Release version to patch'
required: false
default: latest
type: string
track:
description: 'Shorebird track (stable also patches beta so testers never lag)'
required: false
default: stable
type: choice
options:
- stable
- beta
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
jobs:
guard:
name: Reject main branch
runs-on: ubuntu-latest
steps:
- name: Fail if dispatched from main
if: github.ref == 'refs/heads/main'
run: |
echo "::error::Patch workflow must not be run from the main branch. Dispatch it from a release branch instead."
exit 1
build:
name: Patch iOS, Android & macOS
needs: guard
# Without this, a Windows-only patch still spun up a macOS runner that
# checked out, installed Shorebird and Flutter, then ran no patch step.
if: inputs.build_mac || inputs.build_android || inputs.build_ios
runs-on: macos-26
permissions:
id-token: write
pages: write
contents: write
steps:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: Rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
uses: ./.github/actions/rename-pubspec-overrides
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Set Up Flutter
uses: ./.github/actions/setup-flutter
- name: Install certificates
if: inputs.build_mac || inputs.build_ios
uses: ./.github/actions/install-certificates
with:
developer-id-application-p12-base64: ${{ secrets.DEVELOPER_ID_APPLICATION_P12_BASE64_MAC }}
developer-id-installer-p12-base64: ${{ secrets.DEVELOPER_ID_INSTALLER_P12_BASE64_MAC }}
p12-password: ${{ secrets.P12_PASSWORD }}
keychain-password: ${{ secrets.KEYCHAIN_PASSWORD }}
appstore-profile-ios-base64: ${{ secrets.APPSTORE_PROFILE_IOS_BASE64 }}
appstore-profile-macos-base64: ${{ secrets.APPSTORE_PROFILE_MACOS_BASE64 }}
appstore-profile-dev-ios-base64: ${{ secrets.APPSTORE_PROFILE_DEV_IOS_BASE64 }}
appstore-profile-liveactivity-base64: ${{ secrets.APPSTORE_PROFILE_LIVEACTIVITY_BASE64 }}
appstore-profile-liveactivity-debug-base64: ${{ secrets.APPSTORE_PROFILE_LIVEACTIVITY_DEBUG_BASE64 }}
- name: Decode Keystore
if: inputs.build_android
uses: ./.github/actions/decode-keystore
with:
keystore-base64: ${{ secrets.KEYSTORE_BASE64 }}
keystore-properties: ${{ secrets.KEYSTORE_PROPERTIES }}
- name: 🚀 Shorebird Patch macOS
if: inputs.build_mac
uses: shorebirdtech/shorebird-patch@v1
with:
platform: macos
release-version: ${{ inputs.release_version }}
args: '--track ${{ inputs.track }} --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch macOS (beta track)
if: inputs.build_mac && inputs.track == 'stable'
uses: shorebirdtech/shorebird-patch@v1
with:
platform: macos
release-version: ${{ inputs.release_version }}
args: '--track beta --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch Android
if: inputs.build_android
uses: shorebirdtech/shorebird-patch@v1
with:
platform: android
release-version: ${{ inputs.release_version }}
args: '--track ${{ inputs.track }} --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols -- --dart-define=REVENUECAT_API_KEY_ANDROID=${{ secrets.REVENUECAT_API_KEY_ANDROID }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch Android (beta track)
if: inputs.build_android && inputs.track == 'stable'
uses: shorebirdtech/shorebird-patch@v1
with:
platform: android
release-version: ${{ inputs.release_version }}
args: '--track beta --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols -- --dart-define=REVENUECAT_API_KEY_ANDROID=${{ secrets.REVENUECAT_API_KEY_ANDROID }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch iOS
if: inputs.build_ios
uses: shorebirdtech/shorebird-patch@v1
with:
platform: ios
release-version: ${{ inputs.release_version }}
args: '--track ${{ inputs.track }} --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch iOS (beta track)
if: inputs.build_ios && inputs.track == 'stable'
uses: shorebirdtech/shorebird-patch@v1
with:
platform: ios
release-version: ${{ inputs.release_version }}
args: '--track beta --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
# macOS, Android and iOS patches all emit --split-debug-info=symbols, so any
# of them produces a symbols/ dir to zip.
- name: Zip Symbols
if: inputs.build_mac || inputs.build_android || inputs.build_ios
run: zip -r symbols.zip symbols/
# Named after the patch/v<version>/<run number> tag the `tag` job pushes.
- name: Upload Symbols
if: inputs.build_mac || inputs.build_android || inputs.build_ios
uses: ./.github/actions/upload-symbols
with:
file: symbols.zip
name: patch-${{ github.run_number }}-apple-android.zip
token: ${{ secrets.SYMBOLS_UPLOAD_TOKEN }}
windows:
name: Patch Windows
needs: guard
if: inputs.build_windows
# Pinned to match build.yml: patches must use the same toolchain as the
# release build, and windows-latest now ships VS 2026 whose MSVC turns the
# STL1011 experimental-coroutine deprecation (hit by the C++/WinRT code in
# bluetooth_low_energy_windows / permission_handler_windows) into a hard
# compile error.
runs-on: windows-2025
steps:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: Rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
uses: ./.github/actions/rename-pubspec-overrides
# Shorebird checks out its Flutter fork under a long temp path; without
# this a cold cache fails with "Filename too long" (Windows MAX_PATH).
- name: Enable git long paths
run: git config --system core.longpaths true
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Set Up Flutter
uses: ./.github/actions/setup-flutter
- name: 🚀 Shorebird Patch Windows
uses: shorebirdtech/shorebird-patch@v1
with:
platform: windows
release-version: ${{ inputs.release_version }}
args: '--track ${{ inputs.track }} --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols-win -- --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch Windows (beta track)
if: inputs.track == 'stable'
uses: shorebirdtech/shorebird-patch@v1
with:
platform: windows
release-version: ${{ inputs.release_version }}
args: '--track beta --allow-asset-diffs --allow-native-diffs --split-debug-info=symbols-win -- --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: Zip Windows Symbols
shell: pwsh
run: |
7z a symbols-win.zip symbols-win/ build/windows/x64/runner/Release/*.pdb
- name: Upload Windows Symbols
uses: ./.github/actions/upload-symbols
with:
file: symbols-win.zip
name: patch-${{ github.run_number }}-windows.zip
token: ${{ secrets.SYMBOLS_UPLOAD_TOKEN }}
linux:
name: Patch Linux
needs: guard
if: inputs.build_linux
# Same runner as the build.yml release: patches must use the same toolchain.
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: Rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
uses: ./.github/actions/rename-pubspec-overrides
- name: Install Linux build dependencies
run: |
sudo apt-get update
# The runner image ships libunwind-14-dev, which conflicts with the
# libunwind-dev that libgstreamer1.0-dev needs.
sudo apt-get remove -y libunwind-14-dev || true
sudo apt-get install -y --no-install-recommends clang cmake ninja-build pkg-config \
libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libpulse-dev libsecret-1-dev \
libayatana-appindicator3-dev libnotify-dev libkeybinder-3.0-dev libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev libsqlite3-dev libudev-dev libevdev-dev
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Set Up Flutter
uses: ./.github/actions/setup-flutter
- name: 🚀 Shorebird Patch Linux
uses: shorebirdtech/shorebird-patch@v1
with:
platform: linux
release-version: ${{ inputs.release_version }}
args: '--track ${{ inputs.track }} --allow-asset-diffs --allow-native-diffs --obfuscate --split-debug-info=symbols-linux -- --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: 🚀 Shorebird Patch Linux (beta track)
if: inputs.track == 'stable'
uses: shorebirdtech/shorebird-patch@v1
with:
platform: linux
release-version: ${{ inputs.release_version }}
args: '--track beta --allow-asset-diffs --allow-native-diffs --obfuscate --split-debug-info=symbols-linux -- --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}'
- name: Zip Linux Symbols
run: zip -r symbols-linux.zip symbols-linux/
- name: Upload Linux Symbols
uses: ./.github/actions/upload-symbols
with:
file: symbols-linux.zip
name: patch-${{ github.run_number }}-linux.zip
token: ${{ secrets.SYMBOLS_UPLOAD_TOKEN }}
tag:
name: Tag source commit
needs: [build, windows, linux]
# Tag the commit this patch was built from, so every OTA patch is traceable
# to its source. Runs only when a patch actually succeeded: at least one
# platform job succeeded and neither failed. always() lets it evaluate even
# when a platform job was skipped (e.g. a Windows-only patch skips `build`);
# a skipped job's result is 'skipped', not 'failure', so it's tolerated. If
# the main-branch guard tripped, both patch jobs are skipped and this is
# skipped too — no tag off main. !cancelled() avoids tagging a cancelled run.
if: >-
always() && !cancelled() &&
(needs.build.result == 'success' || needs.windows.result == 'success' || needs.linux.result == 'success') &&
needs.build.result != 'failure' &&
needs.windows.result != 'failure' &&
needs.linux.result != 'failure'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Checks out github.sha (fixed at dispatch) — the exact commit the patch
# was built from. Push the tag with the built-in GITHUB_TOKEN: this job
# grants it `contents: write` (above), it acts as github-actions[bot] —
# the same identity the tagger is set to below — and no tag protection
# blocks it. The PAT_TOKEN/TOKEN secrets are only read on this repo
# (PAT_TOKEN writes to prop; TOKEN's write scope lapsed after Jan 2026),
# so their persisted credentials 403 on the push. No submodules to tag.
- name: Checkout the patched commit
uses: actions/checkout@v3
with:
token: ${{ github.token }}
- name: Tag the source commit with the patch provenance
env:
TRACK: ${{ inputs.track }}
RELEASE_VERSION: ${{ inputs.release_version }}
BUILD_IOS: ${{ inputs.build_ios }}
BUILD_ANDROID: ${{ inputs.build_android }}
BUILD_MAC: ${{ inputs.build_mac }}
BUILD_WINDOWS: ${{ inputs.build_windows }}
BUILD_LINUX: ${{ inputs.build_linux }}
run: |
set -euo pipefail
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
tag="patch/v${version}/${GITHUB_RUN_NUMBER}"
# Which platforms this run patched (GHA booleans arrive as strings).
platforms=""
if [ "$BUILD_IOS" = "true" ]; then platforms="$platforms ios"; fi
if [ "$BUILD_ANDROID" = "true" ]; then platforms="$platforms android"; fi
if [ "$BUILD_MAC" = "true" ]; then platforms="$platforms macos"; fi
if [ "$BUILD_WINDOWS" = "true" ]; then platforms="$platforms windows"; fi
if [ "$BUILD_LINUX" = "true" ]; then platforms="$platforms linux"; fi
platforms="${platforms# }"
# Idempotent: a re-run reuses the run number, so don't fail if it exists.
if git ls-remote --tags origin "refs/tags/${tag}" | grep -q .; then
echo "Tag ${tag} already exists on origin — skipping."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${tag}" "${GITHUB_SHA}" \
-m "Shorebird patch (track ${TRACK})" \
-m "release_version: ${RELEASE_VERSION}" \
-m "platforms: ${platforms}" \
-m "run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
git push origin "refs/tags/${tag}"
echo "Tagged ${GITHUB_SHA} as ${tag}"