Skip to content

Update android.yml

Update android.yml #7

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: |
assets_url=${{ steps.create_release.outputs.upload_url }}
asset_path=./app/build/outputs/apk/release/app-release.apk
asset_name=app-v${{ env.version }}.apk
# Strip the URL to the base for the upload
base_url=${assets_url%\{*}
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/vnd.android.package-archive" \
--data-binary "@$asset_path" \
"$base_url?name=$asset_name"