From 84da393e0de76f35b1c8f0ed53739d86438ecd27 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:16:49 +0200 Subject: [PATCH] feat(ci-cd): Build and upload app on publish events --- .github/actions/prepare-keystore/action.yml | 34 ++++++++++++++ .github/workflows/release-app-github.yaml | 52 +++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 .github/actions/prepare-keystore/action.yml create mode 100644 .github/workflows/release-app-github.yaml diff --git a/.github/actions/prepare-keystore/action.yml b/.github/actions/prepare-keystore/action.yml new file mode 100644 index 00000000..228dc62e --- /dev/null +++ b/.github/actions/prepare-keystore/action.yml @@ -0,0 +1,34 @@ +name: Prepare KeyStore +description: Write the KeyStore file and properties to disk + +inputs: + signingStorePassword: + description: 'The password for the KeyStore' + required: true + signingKeyPassword: + description: 'The password for the Key' + required: true + signingKeyAlias: + description: 'The alias for the Key' + required: true + keyStoreBase64: + description: 'The KeyStore file encoded as base64' + required: true + +runs: + using: composite + steps: + - name: Write Keystore file 🗄️ + id: android_keystore + uses: timheuer/base64-to-file@v1.0.3 + with: + fileName: key.jks + encodedString: ${{ inputs.keyStoreBase64 }} + + - name: Write Keystore properties 🗝️ + shell: bash + run: | + echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > key.properties + echo "storePassword=${{ inputs.signingStorePassword }}" >> key.properties + echo "keyPassword=${{ inputs.signingKeyPassword }}" >> key.properties + echo "keyAlias=${{ inputs.signingKeyAlias }}" >> key.properties diff --git a/.github/workflows/release-app-github.yaml b/.github/workflows/release-app-github.yaml new file mode 100644 index 00000000..0c698bdc --- /dev/null +++ b/.github/workflows/release-app-github.yaml @@ -0,0 +1,52 @@ +name: Build and publish app + +on: + release: + types: [ published ] + +jobs: + release-app-github: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: gradle/wrapper-validation-action@v2 + + - name: Write KeyStore 🗝️ + uses: ./.github/actions/prepare-keystore + with: + signingStorePassword: ${{ secrets.SIGNING_STORE_PASSWORD }} + signingKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} + signingKeyAlias: ${{ secrets.SIGNING_KEY_ALIAS }} + keyStoreBase64: ${{ secrets.KEYSTORE }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: 21 + cache: 'gradle' + + - name: Build APKs 📱 + run: ./gradlew assembleRelease + + - name: Build AABs 📱 + run: ./gradlew bundleRelease + + - name: Upload APKs 🚀 + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + files: app/build/outputs/apk/fdroid/release/*.apk + + - name: Upload APKs bundles 🚀 + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + files: app/build/outputs/bundle/fdroidRelease/*.aab \ No newline at end of file