CI/CD #45
Workflow file for this run
This file contains hidden or 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: CI/CD | |
| on: | |
| # Push on main and release tags | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| # PR | |
| pull_request: | |
| branches: | |
| - 'main' | |
| # Manual trigger | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: CI/CD | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Cancel previous runs | |
| uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1 | |
| with: | |
| access_token: ${{ github.token }} | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Set up JDK 17 and gradle cache | |
| id: java | |
| uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| - name: Check if main repo | |
| id: is_main_repo | |
| run: | | |
| if [ $GITHUB_REPOSITORY == 'openremote/console-android' ]; then | |
| echo "value=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run assemble | |
| if: ${{ !steps.is_main_repo.outputs.value || github.event_name == 'pull_request' }} | |
| run: | | |
| gradle assemble | |
| - name: Run assemble and publish | |
| if: ${{ steps.is_main_repo.outputs.value && github.event_name != 'pull_request' }} | |
| run: | | |
| echo "$KEYSTORE_BASE64" | base64 -d > keystore | |
| gradle assemble publishToSonatype closeAndReleaseSonatypeStagingRepository \ | |
| -PsigningKey=$MAVEN_SIGNING_KEY -PsigningPassword=$MAVEN_SIGNING_PASSWORD -PpublishUsername=$MAVEN_USERNAME -PpublishPassword=$MAVEN_PASSWORD \ | |
| -PkeystoreKeyAlias=$KEYSTORE_KEY_ALIAS -PkeystoreKeyPassword=$KEYSTORE_KEY_PASSWORD -PkeystoreFile=$PWD/keystore -PkeystorePassword=$KEYSTORE_PASSWORD | |
| env: | |
| MAVEN_SIGNING_KEY: ${{ secrets._TEMP_MAVEN_SIGNING_KEY || secrets.MAVEN_SIGNING_KEY }} | |
| MAVEN_SIGNING_PASSWORD: ${{ secrets._TEMP_MAVEN_SIGNING_PASSWORD || secrets.MAVEN_SIGNING_PASSWORD }} | |
| MAVEN_USERNAME: ${{ secrets._TEMP_MAVEN_USERNAME || secrets.MAVEN_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets._TEMP_MAVEN_PASSWORD || secrets.MAVEN_PASSWORD }} | |
| KEYSTORE_BASE64: | | |
| ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
| KEYSTORE_KEY_ALIAS: ${{ secrets.ANDROID_KEYSTORE_KEY_ALIAS }} | |
| KEYSTORE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }} | |
| - name: Upload build outputs | |
| if: success() | |
| uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4 | |
| with: | |
| name: build-outputs | |
| path: | | |
| **/build/outputs/**/*.aar | |
| **/build/outputs/**/*.apk |