Skip to content

Update android.yml

Update android.yml #8

Workflow file for this run

name: Android Build and Release
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build release APK
run: ./gradlew assembleRelease
- name: Upload APK as artifact
uses: actions/upload-artifact@v2
with:
name: app-release.apk
path: app/build/outputs/apk/release/app-release.apk
- name: Get app version
id: app_version
run: |
version=$(grep 'versionName "' app/build.gradle | awk -F'"' '{print $2}')
echo "version=$version" >> $GITHUB_ENV
echo "VERSION: $version"
- name: Create 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 }}
draft: false
prerelease: false
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_id=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.version }} \
| jq -r '.id')
upload_url="https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=app-v${{ env.version }}.apk"
asset_path=./app/build/outputs/apk/release/app-release.apk
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/vnd.android.package-archive" \
--data-binary "@$asset_path" \
"$upload_url"