Skip to content

Update android.yml

Update android.yml #5

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}')
code=$(grep 'versionCode ' app/build.gradle | awk -F' ' '{print $2}')
echo "::set-output name=version::$version"
echo "::set-output name=code::$code"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.app_version.outputs.version }}
release_name: Release v${{ steps.app_version.outputs.version }}
draft: false
prerelease: false
- name: Upload 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: ./app/build/outputs/apk/release/app-release.apk
asset_name: app-v${{ steps.app_version.outputs.version }}.apk
asset_content_type: application/vnd.android.package-archive