Skip to content

Instantly share code, notes, and snippets.

@elyeandre
Created July 25, 2024 23:50
Show Gist options
  • Save elyeandre/192f82572eb5565a3fc9098dc114a8d5 to your computer and use it in GitHub Desktop.
Save elyeandre/192f82572eb5565a3fc9098dc114a8d5 to your computer and use it in GitHub Desktop.
cordova-build-android-github-action
name: Build Streamely App
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '17'
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: Cache Gradle files
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install Cordova
run: npm install -g cordova
- name: Add Android platform
run: cordova platform add android
- name: Install app dependencies
run: npm install
- name: Decrypt Keystore
run: |
echo "${{ secrets.STREAMELY_RELEASE_KEY }}" > streamely.release-key.asc
gpg -d --passphrase "${{ secrets.STREAMELY_RELEASE_PASSPHRASE }}" --batch streamely.release-key.asc > streamely-release-key.jks
- name: Build release APK using Cordova
run: cordova build android --release -- --packageType=apk --keystore=streamely-release-key.jks --storePassword=${{ secrets.KEYSTORE_PASSWORD }} --alias=${{ secrets.KEY_ALIAS }} --password=${{ secrets.KEY_PASSWORD }}
- name: Get version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package-version.outputs.current-version }}
release_name: streamely-v${{ steps.package-version.outputs.current-version }}
draft: false
prerelease: false
- name: Upload APK as artifact
uses: actions/upload-artifact@v4
with:
name: streamely
path: platforms/android/app/build/outputs/apk/release/app-release.apk
- name: Upload release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: platforms/android/app/build/outputs/apk/release/app-release.apk
asset_name: streamely-v${{ steps.package-version.outputs.current-version }}.apk
asset_content_type: application/vnd.android.package-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment