Update README.md #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: react-native-android-build-apk | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
install-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install npm dependencies | |
run: npm install | |
build-android: | |
needs: install-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install npm dependencies | |
run: npm install | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Set up Android SDK | |
uses: android-actions/setup-android@v2 | |
with: | |
api-level: 30 | |
target: default | |
build-tools: 29.0.3 | |
- name: Setup build tool version variable | |
shell: bash | |
run: | | |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | |
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | |
echo Last build tool version is: $BUILD_TOOL_VERSION | |
- name: Decode Keystore | |
run: echo "${{ secrets.ANDROID_SIGNING_KEY }}" | base64 --decode > android/app/my-upload-key.keystore | |
- name: Build Android Release | |
run: cd android && ./gradlew assembleRelease --no-daemon | |
- name: Sign APK | |
id: sign_app | |
uses: r0adkll/sign-android-release@v1 | |
with: | |
releaseDirectory: android/app/build/outputs/apk/release | |
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | |
alias: ${{ secrets.ANDROID_ALIAS }} | |
keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
env: | |
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: app-release.apk | |
path: android/app/build/outputs/apk/release/ | |
release-android: | |
name: Create Android Release | |
runs-on: ubuntu-latest | |
needs: build-android | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: app-release.apk | |
- name: Test artifact download | |
run: ls -R | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Read release info from JSON | |
id: read_release_info | |
run: | | |
echo "RELEASE_NAME=$(jq -r '.release_name' release-info.json)" >> $GITHUB_ENV | |
echo "RELEASE_NUMBER=$(jq -r '.release_number' release-info.json)" >> $GITHUB_ENV | |
echo "RELEASE_BODY=$(jq -r '.body' release-info.json)" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.run_number }} | |
release_name: ${{ env.RELEASE_NAME }} | |
body: ${{ env.RELEASE_BODY }} | |
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-release.apk | |
asset_name: scout24-v${{ env.RELEASE_NUMBER }}.apk | |
asset_content_type: application/vnd.android.package-archive |