Skip to content

Run Apple CI builds sequentially #34

Run Apple CI builds sequentially

Run Apple CI builds sequentially #34

Workflow file for this run

name: Build Selene
on:
push:
tags:
- 'v*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
actions: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- name: android
os: ubuntu-latest
build-args: "--android-only"
- name: macos_ios
os: macos-latest
build-args: "--apple-only --sequential"
- name: windows-amd64
os: windows-latest
runs-on: ${{ matrix.os }}
env:
NDK_VERSION: '29.0.14033849'
NDK_VERSION_DEPS: '27.0.12077973'
name: Build ${{ matrix.name }}
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Clone repository
run: |
git clone https://${{ secrets.PULL_TOKEN }}@${{ secrets.REPO_URL }}.git .
shell: bash
- name: Get version from pubspec.yaml
id: get_version
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
VERSION=$(powershell -Command "(Get-Content pubspec.yaml | Select-String '^version:' | ForEach-Object {\$_ -replace 'version: ', ''}).trim()")
else
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | tr -d ' ')
fi
VERSION=$(echo "$VERSION" | cut -d'+' -f1)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
shell: bash
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.44.0'
channel: stable
cache: true
- name: Disable Swift Package Manager for Apple builds
if: matrix.name == 'macos_ios'
run: |
flutter config --no-enable-swift-package-manager
shell: bash
- name: Install Java
if: matrix.name == 'android'
uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: 21
- name: Setup Android SDK
if: matrix.name == 'android'
uses: android-actions/setup-android@v3
- name: Cache Gradle
if: matrix.name == 'android'
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
android/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache NDK
if: matrix.name == 'android'
id: cache-ndk
uses: actions/cache@v4
with:
path: |
${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION }}
${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION_DEPS }}
key: ${{ runner.os }}-ndk-${{ env.NDK_VERSION }}-${{ env.NDK_VERSION_DEPS }}
- name: Install NDK
if: matrix.name == 'android' && steps.cache-ndk.outputs.cache-hit != 'true'
run: |
echo "y" | sdkmanager --install "ndk;${{ env.NDK_VERSION }}"
echo "y" | sdkmanager --install "ndk;${{ env.NDK_VERSION_DEPS }}"
- name: Write sign info
if: matrix.name == 'android'
run: |
if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
echo "Writing signing configuration..."
echo ${{ secrets.SIGNING_KEY }} | base64 --decode > ${{ github.workspace }}/key.jks
cat > android/key.properties << EOF
storePassword=${{ secrets.KEY_STORE_PASSWORD }}
keyPassword=${{ secrets.KEY_PASSWORD }}
keyAlias=${{ secrets.ALIAS }}
storeFile=${{ github.workspace }}/key.jks
EOF
echo "Signing configuration written successfully"
else
echo "WARNING: SIGNING_KEY secret is not set!"
fi
shell: bash
- name: Build with build.sh (Android/macOS/iOS)
if: matrix.name != 'windows-amd64'
run: |
chmod +x build.sh
./build.sh ${{ matrix.build-args }}
shell: bash
- name: Build on Windows
if: matrix.name == 'windows-amd64'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$version = "${{ steps.get_version.outputs.version }}"
Write-Host "Building version: $version" -ForegroundColor Green
flutter pub get
New-Item -ItemType Directory -Force -Path dist | Out-Null
Write-Host "Building Windows..." -ForegroundColor Blue
flutter build windows --release
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$releasePath = "build/windows/x64/runner/Release"
if (-not (Test-Path $releasePath)) {
throw "Windows release directory not found: $releasePath"
}
Compress-Archive `
-Path "$releasePath/*" `
-DestinationPath "dist/selene-$version-windows-x64-portable.zip" `
-Force
Write-Host "Windows build complete" -ForegroundColor Green
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}-release-artifacts
path: dist/*
if-no-files-found: error
create-release:
needs: build
runs-on: ubuntu-latest
name: Create Release
if: startsWith(github.ref, 'refs/tags/')
env:
TZ: Asia/Shanghai
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Prepare release artifacts
run: |
mkdir -p release-files
find all-artifacts -type f -exec cp {} release-files/ \;
if [ -z "$(find release-files -type f -print -quit)" ]; then
echo "No release artifacts found"
exit 1
fi
ls -lh release-files/
- name: Get version from tag
id: tag_version
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Release version: $VERSION"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_version.outputs.version }}
name: Selene ${{ steps.tag_version.outputs.version }}
files: release-files/*
draft: false
prerelease: false
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Release Notes
id: release_notes
run: |
RELEASE_INFO=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.tag_version.outputs.version }}")
RELEASE_BODY=$(echo "$RELEASE_INFO" | python3 -c "import sys, json; data=json.load(sys.stdin); print(data.get('body', '') if 'body' in data else '')")
{
echo 'notes<<EOF'
echo "$RELEASE_BODY"
echo EOF
} >> $GITHUB_OUTPUT
echo "Release notes length: ${#RELEASE_BODY}"
cleanup:
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 2