Use the Forgejo release API via curl instead of the GitHub-only create-release/upload-release-asset actions, and pick the APK with the highest version number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.8 KiB
YAML
51 lines
1.8 KiB
YAML
name: Create Release
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "releases/*.apk"
|
|
|
|
jobs:
|
|
create-release:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Checkout repository
|
|
- name: Checkout Repository
|
|
uses: https://data.forgejo.org/actions/checkout@v4
|
|
|
|
# Get latest APK file (highest version number)
|
|
- name: Find Latest APK
|
|
run: |
|
|
LATEST_APK=$(ls releases/*.apk | sort -V | tail -n 1)
|
|
APK_NAME=$(basename "$LATEST_APK")
|
|
VERSION=$(echo "$APK_NAME" | grep -oP '\d+\.\d+\.\d+\.\d+')
|
|
echo "LATEST_APK=$LATEST_APK" >> $GITHUB_ENV
|
|
echo "APK_NAME=$APK_NAME" >> $GITHUB_ENV
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
|
|
# Create Forgejo Release and upload APK
|
|
- name: Create Release and Upload APK
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
SHA: ${{ github.sha }}
|
|
run: |
|
|
BODY=$(node -e 'console.log(JSON.stringify({
|
|
tag_name: "v" + process.env.VERSION,
|
|
target_commitish: process.env.SHA,
|
|
name: "Release v" + process.env.VERSION,
|
|
body: "This release contains the latest APK version: **v" + process.env.VERSION + "**",
|
|
draft: false,
|
|
prerelease: false
|
|
}))')
|
|
|
|
RELEASE=$(curl -sS --fail-with-body -X POST "$API/releases" \
|
|
-H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$BODY")
|
|
RELEASE_ID=$(echo "$RELEASE" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s).id))')
|
|
|
|
curl -sS --fail-with-body -X POST "$API/releases/$RELEASE_ID/assets?name=$APK_NAME" \
|
|
-H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$LATEST_APK;type=application/vnd.android.package-archive"
|