Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions .github/workflows/release_apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
if-no-files-found: error

release:
permissions: write-all
permissions:
contents: write
runs-on: ubuntu-latest
needs: build
steps:
Expand All @@ -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