feat: Update build workflow to handle APK release and upload to Gitea
Build Android APK / build-apk (push) Successful in 13m55s
Build Android APK / build-apk (push) Successful in 13m55s
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
name: Build Android APK
|
name: Build Android APK
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- "v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-apk:
|
build-apk:
|
||||||
@@ -14,6 +13,7 @@ jobs:
|
|||||||
BASE_URL: ${{ secrets.BASE_URL }}
|
BASE_URL: ${{ secrets.BASE_URL }}
|
||||||
GOOGLE_SERVER_CLIENT_ID: ${{ secrets.GOOGLE_SERVER_CLIENT_ID }}
|
GOOGLE_SERVER_CLIENT_ID: ${{ secrets.GOOGLE_SERVER_CLIENT_ID }}
|
||||||
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
|
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
|
||||||
|
TOKEN: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -55,6 +55,9 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: flutter pub get
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Install release tooling
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y jq
|
||||||
|
|
||||||
- name: Build release APK
|
- name: Build release APK
|
||||||
run: |
|
run: |
|
||||||
BASE_URL_VALUE="${BASE_URL:-http://127.0.0.1:8000}"
|
BASE_URL_VALUE="${BASE_URL:-http://127.0.0.1:8000}"
|
||||||
@@ -74,9 +77,49 @@ jobs:
|
|||||||
|
|
||||||
"${FLUTTER_CMD[@]}"
|
"${FLUTTER_CMD[@]}"
|
||||||
|
|
||||||
- name: Upload APK artifact
|
- name: Create or update Gitea release and upload APK
|
||||||
uses: actions/upload-artifact@v4
|
run: |
|
||||||
with:
|
if [ -z "${TOKEN}" ]; then
|
||||||
name: reader-app-release-apk
|
echo "Missing required secret: TOKEN"
|
||||||
path: build/app/outputs/flutter-apk/app-release.apk
|
exit 1
|
||||||
if-no-files-found: error
|
fi
|
||||||
|
|
||||||
|
APK_PATH="build/app/outputs/flutter-apk/app-release.apk"
|
||||||
|
if [ ! -f "$APK_PATH" ]; then
|
||||||
|
echo "APK not found at $APK_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
OWNER_REPO="${GITHUB_REPOSITORY}"
|
||||||
|
OWNER="${OWNER_REPO%%/*}"
|
||||||
|
REPO="${OWNER_REPO##*/}"
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
API_BASE="${GITHUB_SERVER_URL}/api/v1"
|
||||||
|
|
||||||
|
RELEASE_JSON=$(curl -sS -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"${API_BASE}/repos/${OWNER}/${REPO}/releases" \
|
||||||
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
|| true)
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id // empty')
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
# Fallback: release may already exist for the tag
|
||||||
|
RELEASE_JSON=$(curl -sS \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${OWNER}/${REPO}/releases/tags/${TAG}")
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id // empty')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Could not resolve release ID for tag ${TAG}"
|
||||||
|
echo "$RELEASE_JSON"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -sS -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@${APK_PATH}" \
|
||||||
|
"${API_BASE}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=reader-app-${TAG}.apk"
|
||||||
|
|||||||
Reference in New Issue
Block a user