From d5afa554dc61b21c80bd958a24d680e2724027d1 Mon Sep 17 00:00:00 2001 From: Praveen Date: Mon, 23 Sep 2024 23:16:22 +0530 Subject: [PATCH] Create build.yml --- .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d02fb0b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +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@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '21' # Adjust the Node.js version according to your project requirements + + - name: Install dependencies + run: | + npm i @capacitor/core + npm install -g @capacitor/cli + npm install + + - name: Build web assets + run: npm run build + + - name: Sync web assets to Android + run: npx cap sync android + + - name: set up JDK + uses: actions/setup-java@v3 + with: + java-version: '22' + distribution: 'temurin' + cache: gradle + + - name: Build Android APK with Gradle + run: | + cd android + chmod +x ./gradlew # Ensure Gradle wrapper has executable permission + ./gradlew assembleRelease + + - 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 }} + token: ${{ secrets.TOKEN }} + draft: false + prerelease: false