mirror of
https://github.com/VibedByKaKi/commet.git
synced 2026-11-12 09:27:15 +01:00
A bare codesign --force re-sign stripped user-selected file rights, so file_picker failed with ENTITLEMENT_NOT_FOUND and the unawaited + handler looked dead. Co-authored-by: Cursor <cursoragent@cursor.com>
559 lines
18 KiB
YAML
559 lines
18 KiB
YAML
name: build
|
||
|
||
on:
|
||
push:
|
||
# Avoid empty skipped runs on the mirror / default branch.
|
||
branches-ignore:
|
||
- main
|
||
- dev
|
||
tags:
|
||
- '*'
|
||
paths:
|
||
- 'commet/**'
|
||
- 'tiamat/**'
|
||
- 'widgets/**'
|
||
- 'rust/**'
|
||
- 'pubspec.yaml'
|
||
- 'pubspec.lock'
|
||
- '.github/workflows/build.yml'
|
||
pull_request:
|
||
paths:
|
||
- 'commet/**'
|
||
- 'tiamat/**'
|
||
- 'widgets/**'
|
||
- 'rust/**'
|
||
- 'pubspec.yaml'
|
||
- 'pubspec.lock'
|
||
- '.github/workflows/build.yml'
|
||
merge_group:
|
||
workflow_dispatch:
|
||
|
||
concurrency:
|
||
group: build-${{ github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
env:
|
||
PROJECT_PATH: commet
|
||
# Stable path so Pub cache works the same on Linux/macOS/Windows runners.
|
||
PUB_CACHE: ${{ github.workspace }}/.pub-cache
|
||
|
||
jobs:
|
||
# One codegen pass for the whole matrix — saves ~2–3m × (N-1) billed minutes.
|
||
codegen:
|
||
if: github.ref != 'refs/heads/dev'
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Cache Pub packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ env.PUB_CACHE }}
|
||
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
|
||
restore-keys: |
|
||
pub-${{ runner.os }}-
|
||
|
||
- name: Setup Flutter
|
||
uses: subosito/flutter-action@v2.8.0
|
||
with:
|
||
flutter-version: '3.41.9'
|
||
channel: 'stable'
|
||
cache: true
|
||
|
||
- name: Code Generation
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
dart run scripts/codegen.dart
|
||
|
||
# Stage a directory (not a lone file with archive:false) so the artifact
|
||
# name stays `codegen` and download-artifact can find it.
|
||
- name: Stage generated sources
|
||
run: |
|
||
set -euo pipefail
|
||
STAGE="$GITHUB_WORKSPACE/codegen-out"
|
||
mkdir -p "$STAGE"
|
||
cp -a "$PROJECT_PATH/lib/generated" "$STAGE/generated"
|
||
cd "$PROJECT_PATH"
|
||
find . -name '*.g.dart' -print0 | while IFS= read -r -d '' f; do
|
||
mkdir -p "$STAGE/$(dirname "$f")"
|
||
cp -a "$f" "$STAGE/$f"
|
||
done
|
||
ls -la "$STAGE"
|
||
|
||
- name: Upload generated sources
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: codegen
|
||
path: codegen-out/
|
||
retention-days: 1
|
||
|
||
build-windows:
|
||
# Full matrix only when a tag is created. Pushes to `dev` skip all jobs.
|
||
if: startsWith(github.ref, 'refs/tags/')
|
||
needs: codegen
|
||
runs-on: windows-2022
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Artifact version
|
||
id: meta
|
||
shell: bash
|
||
run: |
|
||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||
v="${GITHUB_REF_NAME}"
|
||
else
|
||
v="${GITHUB_SHA:0:7}"
|
||
fi
|
||
echo "version=${v//\//-}" >> "$GITHUB_OUTPUT"
|
||
echo "version_tag=${v}" >> "$GITHUB_OUTPUT"
|
||
echo "git_hash=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
|
||
echo "build_date=$(($(date +%s)*1000))" >> "$GITHUB_OUTPUT"
|
||
echo "build_detail=ci" >> "$GITHUB_OUTPUT"
|
||
|
||
- name: Cache Pub packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ env.PUB_CACHE }}
|
||
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
|
||
restore-keys: |
|
||
pub-${{ runner.os }}-
|
||
|
||
- name: Setup Flutter
|
||
uses: subosito/flutter-action@v2.8.0
|
||
with:
|
||
flutter-version: '3.41.9'
|
||
channel: 'stable'
|
||
cache: true
|
||
|
||
- name: Configure Flutter
|
||
run: flutter config --enable-windows-desktop
|
||
|
||
- name: Download generated sources
|
||
uses: actions/download-artifact@v8
|
||
with:
|
||
name: codegen
|
||
path: codegen-out
|
||
|
||
- name: Restore generated sources
|
||
shell: bash
|
||
run: |
|
||
set -euo pipefail
|
||
cp -a codegen-out/generated "$PROJECT_PATH/lib/generated"
|
||
if compgen -G 'codegen-out/**/*.g.dart' > /dev/null; then
|
||
cd codegen-out
|
||
find . -name '*.g.dart' -print0 | while IFS= read -r -d '' f; do
|
||
mkdir -p "$GITHUB_WORKSPACE/$PROJECT_PATH/$(dirname "$f")"
|
||
cp -a "$f" "$GITHUB_WORKSPACE/$PROJECT_PATH/$f"
|
||
done
|
||
fi
|
||
|
||
- name: Pub get
|
||
run: |
|
||
cd .\commet
|
||
git config --global core.longpaths true
|
||
flutter pub get
|
||
|
||
- name: Build Windows App
|
||
run: |
|
||
cd .\commet
|
||
flutter build windows --release `
|
||
--dart-define PLATFORM=windows `
|
||
--dart-define VERSION_TAG=${{ steps.meta.outputs.version_tag }} `
|
||
--dart-define GIT_HASH=${{ steps.meta.outputs.git_hash }} `
|
||
--dart-define BUILD_DATE=${{ steps.meta.outputs.build_date }} `
|
||
--dart-define BUILD_DETAIL=${{ steps.meta.outputs.build_detail }}
|
||
|
||
- name: Upload Artifact
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: commet-windows-${{ steps.meta.outputs.version }}
|
||
path: commet/build/windows/x64/runner/Release
|
||
retention-days: 90
|
||
|
||
build-macos:
|
||
if: github.ref != 'refs/heads/dev'
|
||
needs: codegen
|
||
runs-on: macos-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Artifact version
|
||
id: meta
|
||
run: |
|
||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||
v="${GITHUB_REF_NAME}"
|
||
else
|
||
v="${GITHUB_SHA:0:7}"
|
||
fi
|
||
echo "version=${v//\//-}" >> "$GITHUB_OUTPUT"
|
||
echo "version_tag=${v}" >> "$GITHUB_OUTPUT"
|
||
echo "git_hash=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
|
||
echo "build_date=$(($(date +%s)*1000))" >> "$GITHUB_OUTPUT"
|
||
echo "build_detail=ci" >> "$GITHUB_OUTPUT"
|
||
|
||
- name: Cache Pub packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ env.PUB_CACHE }}
|
||
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
|
||
restore-keys: |
|
||
pub-${{ runner.os }}-
|
||
|
||
- name: Setup Flutter
|
||
uses: subosito/flutter-action@v2.8.0
|
||
with:
|
||
flutter-version: '3.41.9'
|
||
channel: 'stable'
|
||
cache: true
|
||
|
||
- name: Cache CocoaPods
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: |
|
||
~/Library/Caches/CocoaPods
|
||
~/.cocoapods/repos
|
||
key: cocoapods-${{ runner.os }}-${{ hashFiles('commet/pubspec.yaml', 'pubspec.lock') }}
|
||
restore-keys: |
|
||
cocoapods-${{ runner.os }}-
|
||
|
||
- name: Configure Flutter
|
||
run: flutter config --enable-macos-desktop
|
||
|
||
- name: Download generated sources
|
||
uses: actions/download-artifact@v8
|
||
with:
|
||
name: codegen
|
||
path: codegen-out
|
||
|
||
- name: Restore generated sources
|
||
run: |
|
||
set -euo pipefail
|
||
cp -a codegen-out/generated "$PROJECT_PATH/lib/generated"
|
||
cd codegen-out
|
||
find . -name '*.g.dart' -print0 | while IFS= read -r -d '' f; do
|
||
mkdir -p "$GITHUB_WORKSPACE/$PROJECT_PATH/$(dirname "$f")"
|
||
cp -a "$f" "$GITHUB_WORKSPACE/$PROJECT_PATH/$f"
|
||
done
|
||
|
||
- name: Pub get
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter pub get
|
||
|
||
- name: Align CocoaPods WebRTC-SDK pins
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
bash scripts/align_macos_webrtc_pods.sh
|
||
|
||
- name: Build macOS App
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter build macos --release \
|
||
--dart-define PLATFORM=macos \
|
||
--dart-define VERSION_TAG=${{ steps.meta.outputs.version_tag }} \
|
||
--dart-define GIT_HASH=${{ steps.meta.outputs.git_hash }} \
|
||
--dart-define BUILD_DATE=${{ steps.meta.outputs.build_date }} \
|
||
--dart-define BUILD_DETAIL=${{ steps.meta.outputs.build_detail }}
|
||
|
||
- name: Sign and package .app
|
||
run: |
|
||
set -euo pipefail
|
||
APP="$PROJECT_PATH/build/macos/Build/Products/Release/commet.app"
|
||
ENTITLEMENTS="$PROJECT_PATH/macos/Runner/Release.entitlements"
|
||
# Ad-hoc sign so embedded frameworks (e.g. Ass) load. Must pass
|
||
# --entitlements: a bare re-sign strips sandbox file-access rights and
|
||
# file_picker then fails with ENTITLEMENT_NOT_FOUND (button looks dead).
|
||
codesign --force --deep --sign - --entitlements "$ENTITLEMENTS" "$APP"
|
||
codesign --verify --deep --strict "$APP"
|
||
codesign -d --entitlements :- "$APP" 2>/dev/null \
|
||
| grep -q 'com.apple.security.files.user-selected.read-write'
|
||
mkdir -p dist
|
||
# KeepParent so the zip's top-level folder is commet.app, not the artifact name.
|
||
ditto -c -k --keepParent "$APP" "dist/commet-macos-${{ steps.meta.outputs.version }}.zip"
|
||
|
||
- name: Upload Artifact
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
path: dist/commet-macos-${{ steps.meta.outputs.version }}.zip
|
||
archive: false
|
||
retention-days: 90
|
||
|
||
build-android:
|
||
if: github.ref != 'refs/heads/dev'
|
||
needs: codegen
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
# Free disk without wiping hostedtoolcache (that forces a full Flutter reinstall).
|
||
# Skip docker prune — runners rarely have useful images here and it costs ~20–40s.
|
||
- name: Free disk space
|
||
run: |
|
||
sudo rm -rf /usr/share/dotnet /usr/local/.ghcup /usr/local/julia* \
|
||
/usr/local/share/chromium /opt/microsoft /opt/google /opt/az || true
|
||
df -h
|
||
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Artifact version
|
||
id: meta
|
||
run: |
|
||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||
v="${GITHUB_REF_NAME}"
|
||
else
|
||
v="${GITHUB_SHA:0:7}"
|
||
fi
|
||
echo "version=${v//\//-}" >> "$GITHUB_OUTPUT"
|
||
echo "version_tag=${v}" >> "$GITHUB_OUTPUT"
|
||
echo "git_hash=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
|
||
echo "build_date=$(($(date +%s)*1000))" >> "$GITHUB_OUTPUT"
|
||
echo "build_detail=ci" >> "$GITHUB_OUTPUT"
|
||
|
||
- name: Cache Pub packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ env.PUB_CACHE }}
|
||
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
|
||
restore-keys: |
|
||
pub-${{ runner.os }}-
|
||
|
||
- name: Setup Flutter
|
||
uses: subosito/flutter-action@v2.8.0
|
||
with:
|
||
flutter-version: '3.41.9'
|
||
channel: 'stable'
|
||
cache: true
|
||
|
||
- name: Setup Java
|
||
uses: actions/setup-java@v4
|
||
with:
|
||
distribution: temurin
|
||
java-version: 17
|
||
|
||
# Full ~/.gradle cache was ~4GB and cost ~1–1.5m on every Post Setup Java save.
|
||
- name: Cache Gradle dependencies
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: |
|
||
~/.gradle/caches/modules-2
|
||
~/.gradle/wrapper
|
||
key: gradle-modules-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'pubspec.lock') }}
|
||
restore-keys: |
|
||
gradle-modules-${{ runner.os }}-
|
||
|
||
- name: Download generated sources
|
||
uses: actions/download-artifact@v8
|
||
with:
|
||
name: codegen
|
||
path: codegen-out
|
||
|
||
- name: Restore generated sources
|
||
run: |
|
||
set -euo pipefail
|
||
cp -a codegen-out/generated "$PROJECT_PATH/lib/generated"
|
||
cd codegen-out
|
||
find . -name '*.g.dart' -print0 | while IFS= read -r -d '' f; do
|
||
mkdir -p "$GITHUB_WORKSPACE/$PROJECT_PATH/$(dirname "$f")"
|
||
cp -a "$f" "$GITHUB_WORKSPACE/$PROJECT_PATH/$f"
|
||
done
|
||
|
||
- name: Pub get
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter pub get
|
||
|
||
# arm64-only: fat multi-ABI APKs dominated the ~10m Build APK step.
|
||
- name: Build APK
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter build apk --debug --target-platform=android-arm64 \
|
||
--dart-define PLATFORM=android \
|
||
--dart-define VERSION_TAG=${{ steps.meta.outputs.version_tag }} \
|
||
--dart-define GIT_HASH=${{ steps.meta.outputs.git_hash }} \
|
||
--dart-define BUILD_DATE=${{ steps.meta.outputs.build_date }} \
|
||
--dart-define BUILD_DETAIL=${{ steps.meta.outputs.build_detail }}
|
||
|
||
- name: Prepare APK for upload
|
||
id: prepare
|
||
run: |
|
||
DEST="commet-android-debug-arm64-${{ steps.meta.outputs.version }}.apk"
|
||
cp "$PROJECT_PATH/build/app/outputs/flutter-apk/app-debug.apk" "$DEST"
|
||
echo "apk_filename=${DEST}" >> "$GITHUB_OUTPUT"
|
||
|
||
- name: Upload Artifact
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
path: ${{ steps.prepare.outputs.apk_filename }}
|
||
archive: false
|
||
retention-days: 90
|
||
|
||
build-linux:
|
||
if: github.ref != 'refs/heads/dev'
|
||
needs: codegen
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Artifact version
|
||
id: meta
|
||
run: |
|
||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||
v="${GITHUB_REF_NAME}"
|
||
else
|
||
v="${GITHUB_SHA:0:7}"
|
||
fi
|
||
echo "version=${v//\//-}" >> "$GITHUB_OUTPUT"
|
||
echo "version_tag=${v}" >> "$GITHUB_OUTPUT"
|
||
echo "git_hash=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
|
||
echo "build_date=$(($(date +%s)*1000))" >> "$GITHUB_OUTPUT"
|
||
echo "build_detail=ci" >> "$GITHUB_OUTPUT"
|
||
|
||
- name: Cache Pub packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ env.PUB_CACHE }}
|
||
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
|
||
restore-keys: |
|
||
pub-${{ runner.os }}-
|
||
|
||
- name: Setup Flutter
|
||
uses: subosito/flutter-action@v2.8.0
|
||
with:
|
||
flutter-version: '3.41.9'
|
||
channel: 'stable'
|
||
cache: true
|
||
|
||
# Plain apt-get: cache-apt-pkgs-action skips postinst/update-alternatives, so
|
||
# libblas.so.3 / liblapack.so.3 never show up for the linker.
|
||
- name: Setup Tools
|
||
run: |
|
||
sudo apt-get update -y
|
||
sudo apt-get install -y ninja-build libgtk-3-dev libmpv-dev mpv ffmpeg \
|
||
libmimalloc-dev webkit2gtk-4.1 keybinder-3.0 libblas3 liblapack3
|
||
|
||
- name: Download generated sources
|
||
uses: actions/download-artifact@v8
|
||
with:
|
||
name: codegen
|
||
path: codegen-out
|
||
|
||
- name: Restore generated sources
|
||
run: |
|
||
set -euo pipefail
|
||
cp -a codegen-out/generated "$PROJECT_PATH/lib/generated"
|
||
cd codegen-out
|
||
find . -name '*.g.dart' -print0 | while IFS= read -r -d '' f; do
|
||
mkdir -p "$GITHUB_WORKSPACE/$PROJECT_PATH/$(dirname "$f")"
|
||
cp -a "$f" "$GITHUB_WORKSPACE/$PROJECT_PATH/$f"
|
||
done
|
||
|
||
- name: Pub get
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter pub get
|
||
|
||
- name: Build Linux
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter build linux --release \
|
||
--dart-define PLATFORM=linux \
|
||
--dart-define VERSION_TAG=${{ steps.meta.outputs.version_tag }} \
|
||
--dart-define GIT_HASH=${{ steps.meta.outputs.git_hash }} \
|
||
--dart-define BUILD_DATE=${{ steps.meta.outputs.build_date }} \
|
||
--dart-define BUILD_DETAIL=${{ steps.meta.outputs.build_detail }}
|
||
|
||
- name: Bundle libmpv and runtime deps
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
bash scripts/bundle_linux_runtime_libs.sh build/linux/x64/release/bundle
|
||
test -f build/linux/x64/release/bundle/lib/libmpv.so.2
|
||
test -f build/linux/x64/release/bundle/lib/libXpresent.so.1
|
||
LD_LIBRARY_PATH="$PWD/build/linux/x64/release/bundle/lib" \
|
||
ldd build/linux/x64/release/bundle/commet.bin | tee /tmp/commet-ldd.txt
|
||
grep -q 'libmpv.so.2 => .*/bundle/lib/libmpv.so.2' /tmp/commet-ldd.txt \
|
||
|| (echo "libmpv was not resolved from the bundle lib dir" >&2; exit 1)
|
||
|
||
- name: Upload Artifact
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: commet-linux-${{ steps.meta.outputs.version }}
|
||
path: commet/build/linux/x64/release/bundle
|
||
retention-days: 90
|
||
|
||
build-web:
|
||
if: startsWith(github.ref, 'refs/tags/')
|
||
needs: codegen
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Artifact version
|
||
id: meta
|
||
run: |
|
||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||
v="${GITHUB_REF_NAME}"
|
||
else
|
||
v="${GITHUB_SHA:0:7}"
|
||
fi
|
||
echo "version=${v//\//-}" >> "$GITHUB_OUTPUT"
|
||
echo "version_tag=${v}" >> "$GITHUB_OUTPUT"
|
||
echo "git_hash=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
|
||
echo "build_date=$(($(date +%s)*1000))" >> "$GITHUB_OUTPUT"
|
||
echo "build_detail=ci" >> "$GITHUB_OUTPUT"
|
||
|
||
- name: Cache Pub packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ env.PUB_CACHE }}
|
||
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
|
||
restore-keys: |
|
||
pub-${{ runner.os }}-
|
||
|
||
- name: Setup Flutter
|
||
uses: subosito/flutter-action@v2.8.0
|
||
with:
|
||
flutter-version: '3.41.9'
|
||
channel: 'stable'
|
||
cache: true
|
||
|
||
- name: Download generated sources
|
||
uses: actions/download-artifact@v8
|
||
with:
|
||
name: codegen
|
||
path: codegen-out
|
||
|
||
- name: Restore generated sources
|
||
run: |
|
||
set -euo pipefail
|
||
cp -a codegen-out/generated "$PROJECT_PATH/lib/generated"
|
||
cd codegen-out
|
||
find . -name '*.g.dart' -print0 | while IFS= read -r -d '' f; do
|
||
mkdir -p "$GITHUB_WORKSPACE/$PROJECT_PATH/$(dirname "$f")"
|
||
cp -a "$f" "$GITHUB_WORKSPACE/$PROJECT_PATH/$f"
|
||
done
|
||
|
||
- name: Pub get
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter pub get
|
||
|
||
- name: Build Web
|
||
run: |
|
||
cd $PROJECT_PATH
|
||
flutter build web --release \
|
||
--dart-define PLATFORM=web \
|
||
--dart-define VERSION_TAG=${{ steps.meta.outputs.version_tag }} \
|
||
--dart-define GIT_HASH=${{ steps.meta.outputs.git_hash }} \
|
||
--dart-define BUILD_DATE=${{ steps.meta.outputs.build_date }} \
|
||
--dart-define BUILD_DETAIL=${{ steps.meta.outputs.build_detail }}
|
||
|
||
- name: Upload Artifact
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: commet-web-${{ steps.meta.outputs.version }}
|
||
path: commet/build/web
|
||
retention-days: 90
|