Fix apk metadata in GitHub Action #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Android apk from Web code | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: [ "apk" ] | |
tags: | |
- "v*.*.*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
- name: Install npm dependencies | |
run: npm install | |
- name: set up JDK 19 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '19' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Create the Android project | |
run: npx cap add android | |
- name: Guarantee scripts execution permission | |
run: chmod +x ./scripts/* | |
- name: Set version number | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: npm run setVersionNumber | |
- name: Build apk | |
run: npm run build-apk | |
- name: Rename bulit apk | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: mv "./android/app/build/outputs/apk/debug/app-debug.apk" "./android/app/build/outputs/apk/debug/hackernews-${{github.ref_name}}.apk" | |
- name: Upload apk when pushing branch "apk" | |
if: startsWith(github.ref, 'refs/heads/apk') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-debug.apk | |
path: './android/app/build/outputs/apk/debug/*.apk' | |
- name: Upload apk when pushing version tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hackernews-${{github.ref_name}}.apk | |
path: './android/app/build/outputs/apk/debug/*.apk' | |
- name: Upload output-metadata.json | |
uses: actions/upload-artifact@v3 | |
with: | |
name: output-metadata.json | |
path: './android/app/build/outputs/apk/debug/output-metadata.json' | |
- name: Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: softprops/action-gh-release@v1 | |
with: | |
# Can't use quotes here | |
files: | | |
./android/app/build/outputs/apk/debug/hackernews-${{github.ref_name}}.apk | |
./android/app/build/outputs/apk/debug/output-metadata.json | |
# Name of the release. defaults to tag name | |
name: apk ${{github.ref_name}} | |