π Splash Up #8
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: Build and Release Android | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
name: Build and Release APK | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # Updated to the latest version | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' # Consider using an LTS version | |
- name: Install dependencies | |
run: | | |
npm i @capacitor/core | |
npm install -g @capacitor/cli | |
npm install | |
- name: Build web assets | |
run: npm run generate | |
- name: Sync web assets to Android | |
run: npx cap sync android | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' # Consider downgrading to Java 17 for compatibility | |
distribution: 'temurin' | |
cache: gradle | |
- name: Build Android APK with Gradle | |
run: | | |
cd android | |
chmod +x ./gradlew # Ensure Gradle wrapper has executable permission | |
./gradlew assembleRelease --stacktrace # Added stacktrace for debugging | |
- name: Move APK to build directory | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/build | |
mv ./android/app/build/outputs/apk/release/app-release.apk $GITHUB_WORKSPACE/build/ | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "build/app-release.apk" | |
tag: v${{ github.run_number }} # Consider a more semantic versioning strategy | |
token: ${{ secrets.TOKEN }} | |
draft: false | |
prerelease: false |