Skip to content

Create Release

Create Release #19

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/actions/wrapper-validation@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
- name: Build app
run: ./gradlew build
env:
SIGNING_KEY_FILE: "debug.keystore"
SIGNING_KEY_ALIAS: "androiddebugkey"
SIGNING_STORE_PASSWORD: "android"
SIGNING_KEY_PASSWORD: "android"
- name: Set release environment variables
run: |
echo "ARM64_APK_SHA256=$(sha256sum app/build/outputs/apk/release/*-arm64-v8a-release.apk | awk '{ print $1 }')" >> $GITHUB_ENV
echo "X86_64_APK_SHA256=$(sha256sum app/build/outputs/apk/release/*-x86_64-release.apk | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Set app version env variables
run: |
VERSION_NAME=$(grep -oP 'versionName\s*"\K[^"]+' app/build.gradle)
VERSION_CODE=$(grep -oP 'versionCode\s*\K\d+' app/build.gradle)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Upload binaries to a release
id: release
uses: softprops/action-gh-release@v2
with:
files: |
app/build/outputs/apk/release/*.apk
tag_name: "v${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}"
- name: Edit release body
run: |
BODY=$(cat <<EOF
### Changes
$(git log --pretty=format:"- %s (@%an)" $(git describe --tags --abbrev=0 `git rev-list --tags --skip=1 --max-count=1 $TAG_NAME`)..$TAG_NAME -- . ':!.github' ':!.github/**' ':!.gitignore' ':!README.md' ':!LICENSE')
### SHA-256 Checksums of APKs
* **arm64-v8a**: \`$ARM64_APK_SHA256\`
* **x86_64**: \`$X86_64_APK_SHA256\`
EOF
)
json_payload=$(jq -n --arg body "$BODY" '{body: $body}')
curl -L -X PATCH -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/$REPO/releases/$RELEASE_ID -d "$json_payload"
env:
TAG_NAME: "v${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}"
ARM64_APK_SHA256: ${{ env.ARM64_APK_SHA256 }}
X86_64_APK_SHA256: ${{ env.X86_64_APK_SHA256 }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
RELEASE_ID: ${{ steps.release.outputs.id }}