Release App #42
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
# Workflow name | |
name: Release App | |
env: | |
main_project_module: app | |
# When it will be triggered | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Application version' | |
required: true | |
default: '1.0' | |
#push: | |
# branches: | |
# - master | |
# Where it will run | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Set Current Date As Env Variable | |
- name: Set current date as env variable | |
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
# Set Repository Name As Env Variable | |
- name: Set repository name as env variable | |
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
- name: Fetch Sources | |
uses: actions/checkout@v2 | |
- name: Setup JDK | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '20' | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v2 | |
# Cache Gradle dependencies and Gradle Wrapper | |
- name: Setup Gradle Cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Generate App Version Name | |
run: echo "VERSION_NAME=v${{ github.run_number }}" >> $GITHUB_ENV | |
- name: Bump Version | |
uses: chkfung/android-version-actions@v1.1 | |
with: | |
gradlePath: app/build.gradle.kts | |
versionCode: ${{ github.run_number }} | |
versionName: ${{ env.VERSION_NAME }} | |
- name: Restore keystore.jks | |
run: echo $KEYSTORE_FILE | base64 -d > /home/runner/work/reactmap-android/reactmap-android/keystore.jks | |
- name: Build apk release project (APK) - ${{ env.main_project_module }} module | |
run: ./gradlew assembleRelease -x test | |
env: | |
SIGNING_KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
SIGNING_STORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
# -PKEYSTORE_FILE="/home/runner/work/reactmap-android/reactmap-android/keystore.jks" | |
# -PKEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }} | |
# -PSIGNING_KEY_ALIAS=${{ secrets.KEY_ALIAS }} | |
# -PSIGNING_KEY_PASSWORD=${{ secrets.KEY_PASSWORD }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Reactmap-android | |
path: ${{ env.main_project_module }}/build/outputs/apk/release/ | |
release: | |
name: Release APK | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download APK from build | |
uses: actions/download-artifact@v3.0.2 | |
with: | |
name: Reactmap-android | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ github.event.inputs.version }} | |
name: Release v${{ github.event.inputs.version }} | |
- name: Upload Release APK | |
id: upload_release_asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: apk/app-release.apk | |
asset_name: reactmap.apk | |
asset_content_type: application/zip |