robosats/.github/workflows/android-build.yml

124 lines
4.3 KiB
YAML
Raw Normal View History

2022-10-20 13:30:44 +00:00
name: "Build: Android"
2022-07-14 17:27:14 +00:00
on:
workflow_dispatch:
workflow_call:
inputs:
semver:
required: true
type: string
2022-07-14 17:27:14 +00:00
push:
branches: [ "main" ]
2022-07-14 17:27:14 +00:00
paths: [ "mobile", "frontend" ]
pull_request:
branches: [ "main" ]
2022-07-14 17:27:14 +00:00
paths: [ "mobile", "frontend" ]
jobs:
build-android:
runs-on: ubuntu-latest
2022-10-25 18:04:12 +00:00
steps:
2022-07-14 17:27:14 +00:00
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Download Android Web.bundle Artifact (built frontend)'
2022-09-29 12:49:01 +00:00
if: inputs.semver == '' # Only if workflow fired from frontend-build.yml
2022-07-14 17:27:14 +00:00
uses: dawidd6/action-download-artifact@v2
with:
workflow: frontend-build.yml
workflow_conclusion: success
name: mobile-web.bundle
path: mobile/html/Web.bundle
2022-07-14 17:27:14 +00:00
2022-09-29 12:49:01 +00:00
- name: 'Download main.js Artifact for a release'
if: inputs.semver != '' # Only if fired as job in release.yml
uses: actions/download-artifact@v3
with:
name: mobile-web.bundle
path: mobile/html/Web.bundle
2022-09-29 12:49:01 +00:00
2022-07-14 17:27:14 +00:00
- name: 'Install npm Dependencies'
run: |
cd mobile
npm install
2022-07-14 17:27:14 +00:00
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
2022-10-25 18:04:12 +00:00
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: 'Build Android Debug'
if: inputs.semver == '' # Only build debug if this is a pre-release
run: |
cd mobile/android
./gradlew assembleDebug
2022-07-14 17:27:14 +00:00
- name: 'Build Android Release'
run: |
cd mobile/android
./gradlew assembleRelease
- name: 'Get Commit Hash'
id: commit
uses: pr-mpt/actions-commit-hash@v1
- name: 'Upload .apk Release Artifact (for Release)'
2022-07-14 17:27:14 +00:00
uses: actions/upload-artifact@v3
if: inputs.semver != '' # If this workflow is called from release.yml
with:
name: robosats-${{ inputs.semver }}.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk
- name: 'Upload .apk Artifact (for Pre-release)'
uses: actions/upload-artifact@v3
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
2022-07-14 17:27:14 +00:00
with:
name: robosats-${{ steps.commit.outputs.short }}.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk
- name: 'Upload .apk Debug Artifact (for Pre-release)'
2022-09-29 12:49:01 +00:00
if: inputs.semver == '' # Only build debug if this is a pre-release
uses: actions/upload-artifact@v3
with:
name: robosats-debug-${{ steps.commit.outputs.short }}.apk
path: mobile/android/app/build/outputs/apk/debug/app-debug.apk
- name: 'Create Pre-release'
id: create_release
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: android-${{ steps.commit.outputs.short }}
release_name: robosats-android-${{ steps.commit.outputs.short }}
2022-09-29 12:49:01 +00:00
changelog: mobile/CHANGELOG.md
draft: false
prerelease: true
- name: 'Upload Pre-release APK Release Asset'
2022-10-25 18:04:12 +00:00
id: upload-release-apk-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/release/app-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}.apk
asset_content_type: application/apk
- name: 'Upload Pre-release APK Debug Asset'
2022-10-25 18:04:12 +00:00
id: upload-debug-apk-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/debug/app-debug.apk
asset_name: robosats-debug-${{ steps.commit.outputs.short }}.apk
asset_content_type: application/apk