From 34e033263454dbb44c60b11cfef6d1a80d16a6cb Mon Sep 17 00:00:00 2001 From: TobiasRoeddiger Date: Mon, 14 Sep 2026 11:53:07 +0200 Subject: [PATCH] ci: fix APK release creation --- .github/workflows/release_apk.yml | 54 +++++++++++++++++++------------ 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release_apk.yml b/.github/workflows/release_apk.yml index 3992ad10..89a6ecd1 100644 --- a/.github/workflows/release_apk.yml +++ b/.github/workflows/release_apk.yml @@ -25,7 +25,8 @@ jobs: if-no-files-found: error release: - permissions: write-all + permissions: + contents: write runs-on: ubuntu-latest needs: build steps: @@ -34,26 +35,37 @@ jobs: with: name: release-apk path: ${{ github.workspace }}/release-apk - - uses: benjlevesque/short-sha@v2.2 - id: short-sha - - name: Create Release - id: create_release - uses: actions/create-release@v1 + - name: Create Release and Upload APK + shell: bash env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - draft: false - prerelease: false - release_name: Release ${{ github.event.head_commit.message }} - tag_name: ${{ env.SHA }} + GH_TOKEN: ${{ github.token }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail - - name: Upload APK as Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/release-apk/app-release.apk - asset_name: app-release.apk - asset_content_type: application/vnd.android.package-archive + tag_name="${GITHUB_SHA::7}" + commit_subject="${COMMIT_MESSAGE%%$'\n'*}" + if [[ -z "$commit_subject" ]]; then + commit_subject="$tag_name" + fi + release_title="Release ${commit_subject:0:248}" + apk_path="$GITHUB_WORKSPACE/release-apk/app-release.apk" + + if gh release view "$tag_name" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + gh release edit "$tag_name" \ + --repo "$GITHUB_REPOSITORY" \ + --title "$release_title" \ + --notes "$COMMIT_MESSAGE" + else + gh release create "$tag_name" \ + --repo "$GITHUB_REPOSITORY" \ + --target "$GITHUB_SHA" \ + --title "$release_title" \ + --notes "$COMMIT_MESSAGE" + fi + + gh release upload "$tag_name" \ + "$apk_path#app-release.apk" \ + --repo "$GITHUB_REPOSITORY" \ + --clobber