Move release workflow to Forgejo Actions
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>
This commit is contained in:
parent
1e013142f8
commit
dd94016e87
2 changed files with 51 additions and 51 deletions
51
.forgejo/workflows/create_release.yml
Normal file
51
.forgejo/workflows/create_release.yml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
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"
|
||||
51
.github/workflows/create_release.yml
vendored
51
.github/workflows/create_release.yml
vendored
|
|
@ -1,51 +0,0 @@
|
|||
name: Create Release
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "releases/*.apk"
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checkout repository
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Get latest APK file
|
||||
- name: Find Latest APK
|
||||
id: find_apk
|
||||
run: |
|
||||
LATEST_APK=$(ls -t releases/*.apk | head -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 GitHub Release
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: v${{ env.VERSION }}
|
||||
release_name: Release v${{ env.VERSION }}
|
||||
body: |
|
||||
This release contains the latest APK version: **v${{ env.VERSION }}**
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
# Upload APK to GitHub Release
|
||||
- name: Upload APK to Release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ${{ env.LATEST_APK }}
|
||||
asset_name: ${{ env.APK_NAME }}
|
||||
asset_content_type: application/vnd.android.package-archive
|
||||
Loading…
Reference in a new issue