diff --git a/.github/workflows/build-deploy-internal.yml b/.github/workflows/build-deploy-internal.yml index 691dd5c8..21c43ddf 100644 --- a/.github/workflows/build-deploy-internal.yml +++ b/.github/workflows/build-deploy-internal.yml @@ -3,59 +3,26 @@ name: Build App & Deploy Internal on: push: branches: [develop] - pull_request: - branches: [develop] workflow_dispatch: jobs: build: - runs-on: ubuntu-latest name: Build - steps: - - - name: Checkout the code - uses: actions/checkout@v3 - - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: oracle - java-version: 17 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Decode Base64 Keystore - env: - KEYSTORE_BASE64: ${{ secrets.ANDROID_SIGNING_KEYSTORE }} - run: echo $KEYSTORE_BASE64 | base64 --decode > keystore.jks - working-directory: ./app - - - name: Get current date for version code - id: date - run: echo "::set-output name=date::$(date +'%y%m%d%H%M')" - - - name: Assemble & Sign App Release Bundle - env: - ONELIST_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEYSTORE_PASSWORD }} - ONELIST_KEYSTORE_ALIAS: ${{ secrets.ONELIST_KEYSTORE_ALIAS }} - ONELIST_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ONELIST_KEYSTORE_ALIAS_PASSWORD }} - run: ./gradlew bundleRelease - - - name: Upload aab - uses: actions/upload-artifact@v4 - with: - name: app-release.aab - path: app/build/outputs/bundle/release/app-release.aab + uses: ./.github/workflows/common-build-workflow.yml + secrets: inherit + with: + upload-artifact: true deploy: - if: github.event_name == 'push' needs: build runs-on: ubuntu-latest name: Deploy steps: + - name: Checkout the code + uses: actions/checkout@v3 + - name: Download aab uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..c9b2210c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,14 @@ +name: Build App + +on: + pull_request: + branches: [develop] + workflow_dispatch: + +jobs: + build: + name: Build + uses: ./.github/workflows/common-build-workflow.yml + secrets: inherit + with: + upload-artifact: false \ No newline at end of file diff --git a/.github/workflows/common-build-workflow.yml b/.github/workflows/common-build-workflow.yml new file mode 100644 index 00000000..41be34cc --- /dev/null +++ b/.github/workflows/common-build-workflow.yml @@ -0,0 +1,58 @@ +name: Build App & Deploy Internal + +on: + workflow_call: + inputs: + upload-artifact: + required: true + type: boolean + +jobs: + build: + runs-on: ubuntu-latest + name: Build App + steps: + + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: oracle + java-version: 17 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Decode Base64 Keystore + env: + KEYSTORE_BASE64: ${{ secrets.ANDROID_SIGNING_KEYSTORE }} + run: echo $KEYSTORE_BASE64 | base64 --decode > keystore.jks + working-directory: ./app + + - name: Prepare Version Code + id: versionCode + run: | + sum=`expr ${{vars.VERSION_CODE_OFFSET}} + ${{github.run_number}}` + echo "versionCode=$sum" >> "$GITHUB_OUTPUT" + + - name: Prepare version.properties + run: | + touch version.properties && \ + echo "VERSION_CODE=${{ steps.versionCode.outputs.versionCode }}" >> version.properties + + - name: Assemble & Sign App Release Bundle + env: + ONELIST_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEYSTORE_PASSWORD }} + ONELIST_KEYSTORE_ALIAS: ${{ secrets.ONELIST_KEYSTORE_ALIAS }} + ONELIST_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ONELIST_KEYSTORE_ALIAS_PASSWORD }} + run: ./gradlew bundleRelease + + - name: Upload aab + if: inputs.upload-artifact + uses: actions/upload-artifact@v4 + with: + name: app-release.aab + path: app/build/outputs/bundle/release/app-release.aab + \ No newline at end of file