Skip to content

Update build-test.yaml #48

Update build-test.yaml

Update build-test.yaml #48

Workflow file for this run

name: Build and Release APK
on:
push:
branches:
- master # Change this to your main branch
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Restore keystore from secret
run: echo "${{ secrets.KEYSTORE_FILE }}" | tr -d '\n' | base64 -d > /home/runner/work/reactmap-android/reactmap-android/keystore.jks
- name: Check if keystore is available
run: ls -a /home/runner/work/reactmap-android/reactmap-android/keystore.jks
- name: Make Gradlew executable
run: chmod +x ./gradlew
- name: Extract versionName from gradle.properties
id: extract_version
run: echo "::set-output name=version::$(grep 'reactmap.versionName' gradle.properties | cut -d'=' -f2 | tr -d '[:space:]')"
- name: Sign APK and create release
run: |
cd /home/runner/work/reactmap-android/reactmap-android/
./gradlew assembleRelease -Pandroid.injected.signing.store.file=/home/runner/work/reactmap-android/reactmap-android/keystore.jks -Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} -Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} -Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }}
- name: List APK directory - apk
run: ls -R /home/runner/work/reactmap-android/reactmap-android/app/build/outputs/apk/
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Reactmap-android
path: /home/runner/work/reactmap-android/reactmap-android/app/build/outputs/apk/release/app-release.apk
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.extract_version.outputs.version }}
release_name: v${{ steps.extract_version.outputs.version }}
draft: false
prerelease: false
- name: Upload Artifact
id: 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: /home/runner/work/reactmap-android/reactmap-android/app/build/outputs/apk/release/app-release.apk
asset_name: pogofuerth-v${{ steps.extract_version.outputs.version }}.apk
asset_content_type: application/octet-stream
- name: Send Discord webhook notification
run: |
release_url="https://github.com/${{ github.repository }}/releases/tag/v${{ steps.extract_version.outputs.version }}"
curl -H "Content-Type: application/json" -X POST -d "{\"content\": \"New release v${{ steps.extract_version.outputs.version }} is available! [View Release]($release_url)\"}" ${{ secrets.DISCORD_WEBHOOK_URL }}
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}