Add Forgejo Release creation on version tag push
Tag pushes (v*) now build the APK and create a Forgejo Release with the APK attached as a downloadable asset, in addition to uploading the workflow artifact. Requires RELEASE_TOKEN secret (write:repository scope). To release: git tag v26.03.09 && git push origin v26.03.09 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,19 @@
|
|||||||
|
# Runs on pushes to main and on version tags (v*).
|
||||||
|
#
|
||||||
|
# Branch push (main): builds APK, uploads as workflow artifact (30 day retention)
|
||||||
|
# Tag push (v26.03.09): builds APK, creates a Forgejo Release with APK attached
|
||||||
|
#
|
||||||
|
# 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
|
name: Build APK
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
tags: ["v*"]
|
||||||
paths:
|
paths:
|
||||||
- "lib/**"
|
- "lib/**"
|
||||||
- "pubspec.yaml"
|
- "pubspec.yaml"
|
||||||
@@ -26,9 +37,41 @@ jobs:
|
|||||||
- name: Build release APK
|
- name: Build release APK
|
||||||
run: flutter build apk --release
|
run: flutter build apk --release
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: fabledapp-${{ github.sha }}
|
name: fabledapp-${{ github.sha }}
|
||||||
path: build/app/outputs/flutter-apk/app-release.apk
|
path: build/app/outputs/flutter-apk/app-release.apk
|
||||||
retention-days: 30
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user