ef4872e24a
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86 lines
2.8 KiB
YAML
86 lines
2.8 KiB
YAML
# Branch push (dev): builds APK, uploads as artifact named fabledapp-dev-<sha>
|
|
# Branch push (main): builds APK, uploads as artifact named fabledapp-<sha>
|
|
# Tag push (v26.03.09): builds APK, uploads artifact + creates Forgejo Release
|
|
#
|
|
# To cut a release:
|
|
# git tag v26.03.09 && git push origin v26.03.09
|
|
#
|
|
# Required secrets (repo → Settings → Secrets → Actions):
|
|
# RELEASE_TOKEN — Forgejo PAT with write:repository scope
|
|
name: Build APK
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
tags: ["v*"]
|
|
paths:
|
|
- "lib/**"
|
|
- "pubspec.yaml"
|
|
- "pubspec.lock"
|
|
- "android/**"
|
|
- "assets/**"
|
|
- ".forgejo/workflows/build.yml"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build release APK
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/cirruslabs/flutter:stable
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Build release APK
|
|
run: flutter build apk --release
|
|
|
|
- name: Set artifact name
|
|
id: artifact
|
|
run: |
|
|
if [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
|
|
echo "name=fabledapp-dev-${{ github.sha }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "name=fabledapp-${{ github.sha }}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: ${{ steps.artifact.outputs.name }}
|
|
path: build/app/outputs/flutter-apk/app-release.apk
|
|
retention-days: 30
|
|
|
|
- name: Create Forgejo release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
echo "Creating release $TAG..."
|
|
|
|
RESPONSE=$(curl -s -X POST \
|
|
"https://git.fabledsword.com/api/v1/repos/bvandeusen/FabledApp/releases" \
|
|
-H "Authorization: token $RELEASE_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"body\": \"\"}")
|
|
|
|
RELEASE_ID=$(echo "$RESPONSE" | grep -oE '"id":[[:space:]]*[0-9]+' | head -1 | grep -oE '[0-9]+')
|
|
|
|
if [ -z "$RELEASE_ID" ]; then
|
|
echo "Failed to create release. API response:"
|
|
echo "$RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Release created with ID $RELEASE_ID, uploading APK..."
|
|
|
|
curl -s -X POST \
|
|
"https://git.fabledsword.com/api/v1/repos/bvandeusen/FabledApp/releases/$RELEASE_ID/assets" \
|
|
-H "Authorization: token $RELEASE_TOKEN" \
|
|
-F "attachment=@build/app/outputs/flutter-apk/app-release.apk"
|
|
|
|
echo "Done — release $TAG is live at:"
|
|
echo "https://git.fabledsword.com/bvandeusen/FabledApp/releases/tag/$TAG"
|