- Add .devcontainer/ci.Dockerfile: bakes Flutter, JDK 17, Android SDK, and flutter precache --android into a single Docker image (~2GB, built once) - ci.yml: build-android uses kryz-ci:latest container — removes 8 redundant SDK download steps (Java 17, Flutter, Android SDK, precache, licenses) that account for ~35-40 min of the 40-min container spin-up time - release.yml: build-android uses kryz-ci:latest container — same reduction from 13 steps to 8. Also fixes hardcoded 'token ***' -> '$GITEA_TOKEN' - devcontainer.json: simplified postCreateCommand (removed venv, pip, claude) and cleaned up invalid JSON (comments, empty mounts array) Estimated impact: 40min -> 5-10min first run (with pre-built image), ~2-3min subsequent runs (Docker layer caching)
215 lines
7.3 KiB
YAML
215 lines
7.3 KiB
YAML
# kryz-go-flutter Release Pipeline
|
|
# Triggers on version tags (v1.0.0, v1.0.1, etc.)
|
|
# Produces signed artifacts and attaches them to a Gitea Release
|
|
#
|
|
# CONTAINER IMAGE: The build-android job uses a pre-built Docker image
|
|
# (kryz-ci:latest) that includes Flutter, JDK 17, and Android SDK baked in.
|
|
# Build once on the runner host:
|
|
# docker build -f .devcontainer/ci.Dockerfile -t kryz-ci:latest .devcontainer
|
|
|
|
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
env:
|
|
FLUTTER_VERSION: "3.44.0"
|
|
|
|
jobs:
|
|
# ── Lint (gate) ─────────────────────────────────────────────
|
|
lint:
|
|
name: Lint
|
|
runs-on: [self-hosted, linux, x64]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Flutter
|
|
run: |
|
|
set -e
|
|
if command -v flutter &> /dev/null; then
|
|
echo "Flutter already installed, skipping download."
|
|
flutter --version
|
|
exit 0
|
|
fi
|
|
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \
|
|
-o /tmp/flutter.tar.xz
|
|
tar -xf /tmp/flutter.tar.xz -C "$PWD"
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
flutter --version
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
flutter pub get
|
|
|
|
- name: Generate stubs (lint gate support)
|
|
if: hashFiles('theme.json') == ''
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
python3 ci_stub_gen.py
|
|
|
|
- name: Analyze Dart code
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
flutter analyze lib/ test/
|
|
|
|
- name: Check formatting
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
dart format --set-exit-if-changed lib/ test/
|
|
|
|
|
|
# ── Test (gate) ──────────────────────────────────────────────────
|
|
test:
|
|
name: Test
|
|
runs-on: [self-hosted, linux, x64]
|
|
needs: [lint]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Flutter
|
|
run: |
|
|
set -e
|
|
if command -v flutter &> /dev/null; then
|
|
echo "Flutter already installed, skipping download."
|
|
flutter --version
|
|
exit 0
|
|
fi
|
|
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \
|
|
-o /tmp/flutter.tar.xz
|
|
tar -xf /tmp/flutter.tar.xz -C "$PWD"
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
flutter --version
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
flutter pub get
|
|
|
|
- name: Generate stubs (lint gate support)
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
python3 ci_stub_gen.py
|
|
|
|
- name: Run tests
|
|
run: |
|
|
export PATH="$PWD/flutter/bin:$PATH"
|
|
flutter test --reporter=expanded
|
|
|
|
|
|
# ── Android release build (uses pre-built container image) ──────
|
|
build-android:
|
|
name: Build Android Release
|
|
runs-on: [self-hosted, linux, x64]
|
|
needs: [test]
|
|
container:
|
|
image: kryz-ci:latest
|
|
options: --user vscode
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Verify environment
|
|
run: |
|
|
echo "=== Environment check ==="
|
|
echo "Flutter: $(flutter --version | head -1)"
|
|
echo "Java: $(java -version 2>&1 | head -1)"
|
|
echo "SDK tools: $(sdkmanager --version)"
|
|
echo "Android SDK: $ANDROID_HOME"
|
|
echo "JAVA_HOME: $JAVA_HOME"
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
python3 -m pip install --upgrade pip || true
|
|
pip install -r requirements.txt || true
|
|
|
|
- name: Install Flutter dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Generate stubs (lint gate support)
|
|
run: python3 ci_stub_gen.py
|
|
|
|
# If release signing secrets are available, write keystore
|
|
# and update build.gradle.kts to use a release signing config.
|
|
# Otherwise fall back to debug keys (current state of the repo).
|
|
- name: Configure release signing
|
|
if: env.ANDROID_KEYSTORE_BASE64 != ''
|
|
env:
|
|
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
|
ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
|
|
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
|
ANDROID_KEY_PASS: ${{ secrets.ANDROID_KEY_PASS }}
|
|
run: |
|
|
echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > android/app/release.keystore
|
|
cat > android/key.properties <<EOF
|
|
storePassword=$ANDROID_KEYSTORE_PASS
|
|
keyPassword=$ANDROID_KEY_PASS
|
|
keyAlias=$ANDROID_KEY_ALIAS
|
|
storeFile=../release.keystore
|
|
EOF
|
|
|
|
- name: Build APK (release)
|
|
run: flutter build apk --release
|
|
|
|
- name: Build App Bundle (release)
|
|
run: flutter build appbundle --release
|
|
|
|
- name: List build outputs
|
|
run: |
|
|
echo "=== APK output ==="
|
|
ls -lh build/app/outputs/flutter-apk/ || true
|
|
echo "=== AAB output ==="
|
|
ls -lh build/app/outputs/bundle/release/ || true
|
|
|
|
- name: "Note: artifact storage not configured"
|
|
run: |
|
|
echo "WARNING: Gitea Actions artifact storage is not configured on this instance."
|
|
echo "Build outputs available in runner workspace:"
|
|
echo " APK: build/app/outputs/flutter-apk/app-release.apk"
|
|
echo " AAB: build/app/outputs/bundle/release/app-release.aab"
|
|
|
|
|
|
# ── iOS release build ───────────────────────────────────────
|
|
# Note: iOS builds require macOS with Xcode. We skip as a no-op
|
|
# on Linux runners. To enable, configure a macOS runner.
|
|
build-ios:
|
|
name: Build iOS Release
|
|
runs-on: [self-hosted, linux, x64]
|
|
needs: [test]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check iOS build feasibility
|
|
run: |
|
|
echo "INFO: iOS builds require macOS host with Xcode."
|
|
echo "Our self-hosted runner runs Linux containers via act."
|
|
echo "Skipping iOS build — it will succeed as a no-op."
|
|
echo "To enable iOS builds, configure a native macOS runner."
|
|
|
|
|
|
# ── Publish Gitea Release ────────────────────────────────────
|
|
publish-release:
|
|
name: Publish Release
|
|
runs-on: [self-hosted, linux, x64]
|
|
needs: [build-android]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create Gitea Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
TAG: ${{ gitea.ref_name }}
|
|
GITEA_BASE: https://git.westerntechnologies.duckdns.org
|
|
run: |
|
|
curl -s -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"body\": \"Automated release build for $TAG\"}" \
|
|
"$GITEA_BASE/api/v1/repos/kfj001/kryz-go-flutter/releases"
|