最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Ionic (7.2.0) + Capacitor (7.0.1) : Build and release signed Android APK with Github Action - Stack Overflow

programmeradmin0浏览0评论

How can I automate the build and deployment of a signed Android app made with Ionic (default config) and Capacitor using GitHub Actions? My app is fully functional, and I want to streamline the deployment process.

How can I automate the build and deployment of a signed Android app made with Ionic (default config) and Capacitor using GitHub Actions? My app is fully functional, and I want to streamline the deployment process.

Share Improve this question asked Feb 6 at 18:04 Romb38Romb38 317 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I just set up a working CI pipeline to build and create a release of an Android APK using Ionic and Capacitor. During my research, I found limited documentation, so I'm sharing my setup here.

To create this CI, I referred to the Ionic documentation on building and syncing.

For generating a signed APK, you'll need a keystore file. I created mine using Android Studio. In Android Studio, navigate to BuildGenerate Signed App Bundle or APK, select APK, and click Create new....

The CI secrets correspond to the following:

  • secrets.KEYSTORE: The keystore (.jks) file encoded in base64. On Debian, I used base64 <keyfile>.jks to generate it.
  • secrets.KEYSTORE_PASS: The password for the keystore file.
  • secrets.KEYSTOREALIAS: The alias name you chose.
  • secrets.KEYSTOREALIAS_PASS: The password set for the alias.
name: Ionic CI/CD with Cypress
on:
  pull_request:
     types: [closed]

jobs:
  build-release-apk:
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout source
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - name: Setup Java
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin' 
          java-version: '21'
      - name: Install Ionic and Capacitor dependencies
        run: npm install -g @ionic/cli @capacitor/core @capacitor/cli

      - name: Install app dependencies
        run: |
            npm install
            npm run build

      - name: Build Ionic app
        env:
            KEYSTOREALIAS_PASS: ${{ secrets.KEYSTOREALIAS_PASS }}
            KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }}
            KEYSTOREALIAS: ${{ secrets.KEYSTOREALIAS }}
            KEYSTORE: ${{ secrets.KEYSTORE }}
        run: |
            echo "$KEYSTORE" | base64 --decode > android/official.jks
            npx cap sync
            npx cap build android --keystorepath official.jks \
                                  --keystorepass "$KEYSTORE_PASS" \
                                  --keystorealias $KEYSTOREALIAS \
                                  --keystorealiaspass "$KEYSTOREALIAS_PASS" \
                                  --androidreleasetype APK
      - name: Release with Notes
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ github.ref_name }}
          token: ${{ secrets.GITHUB_TOKEN }}
          files: |
            android/app/build/outputs/apk/release/app-release-signed.apk
发布评论

评论列表(0)

  1. 暂无评论