|
| 1 | +name: publish |
| 2 | +run-name: "Publish" |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | +jobs: |
| 8 | + build-app: |
| 9 | + runs-on: "ubuntu-latest" |
| 10 | + env: |
| 11 | + BUILD_NUMBER: ${{ github.run_number }} |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + # Determine new version |
| 18 | + |
| 19 | + - name: Collect version prerequisites |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + OLD_VERSION=$(cat version.txt) |
| 23 | + echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV |
| 24 | + echo "PREV_VERSION_REF=$(git rev-list -n 1 $OLD_VERSION)" >> $GITHUB_ENV |
| 25 | + - name: Check if there were any new fix or feature commits |
| 26 | + id: version-check |
| 27 | + uses: inovait/actions-common/bump-version@v11 |
| 28 | + with: |
| 29 | + version: '${{ env.OLD_VERSION }}' |
| 30 | + from: '${{ env.PREV_VERSION_REF }}' |
| 31 | + to: 'HEAD' |
| 32 | + increment: "auto" |
| 33 | + - run: "echo \"No feature or fix commits. Skipping build...\"" |
| 34 | + if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}" |
| 35 | + - uses: andymckay/cancel-action@0.3 |
| 36 | + if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}" |
| 37 | + - name: "Wait for cancel to stick" |
| 38 | + run: "sleep 99999" |
| 39 | + if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}" |
| 40 | + - run: "./config/bump-version.sh ${{ steps.version-check.outputs.version }}" |
| 41 | + - run: "v=$(cat version.txt);echo \"VERSION=$v\" > $GITHUB_ENV" |
| 42 | + - run: "echo \"# Release version ${{ env.VERSION }}\" > $GITHUB_STEP_SUMMARY" |
| 43 | + |
| 44 | + # Build preparations |
| 45 | + - uses: actions/setup-java@v4 |
| 46 | + with: |
| 47 | + java-version: '21' |
| 48 | + distribution: temurin |
| 49 | + cache: gradle |
| 50 | + - name: Setup Android SDK |
| 51 | + uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc |
| 52 | + - name: Validate Gradle Wrapper |
| 53 | + uses: gradle/actions/wrapper-validation@ac638b010cf58a27ee6c972d7336334ccaf61c96 |
| 54 | + - name: Compile library |
| 55 | + run: "./gradlew --parallel assemble" |
| 56 | + - name: Lint |
| 57 | + run: "./gradlew --continue --parallel lintDebug detektMain detektTest buildHealth reportMerge detektReleaseUnitTest -x detektRelease --continue" |
| 58 | + - name: Generate Changelog |
| 59 | + id: changelog |
| 60 | + uses: inovait/actions-common/git-changelog-generator@v8 |
| 61 | + with: |
| 62 | + git_commit_url_prefix: 'https://github.com/pebble-dev/PebbleKitAndroid2/commit/' |
| 63 | + from: '${{ env.PREV_VERSION_REF }}' |
| 64 | + to: 'HEAD' |
| 65 | + # - name: 'Publish' |
| 66 | + # run: './gradlew publishToMavenCentral --no-configuration-cache |
| 67 | + # env: |
| 68 | + # ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 69 | + # ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} |
| 70 | + # ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }} |
| 71 | + # ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_SIGNING_ID }} |
| 72 | + # ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSPHRASE }} |
| 73 | + - name: 'Add changelog and version' |
| 74 | + run: 'git add version.txt' |
| 75 | + - run: 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"' |
| 76 | + - run: 'git config --global user.name "github-actions[bot]"' |
| 77 | + - name: 'Commit changelog and version' |
| 78 | + run: 'git commit -m "chore: release ${{ env.VERSION }}"' |
| 79 | + - name: 'Push changelog and version' |
| 80 | + run: 'git push' |
| 81 | + - name: 'Create tag' |
| 82 | + run: 'git tag ${{ env.VERSION }}' |
| 83 | + - name: 'Push tag' |
| 84 | + run: 'git push origin ${{ env.VERSION }}' |
| 85 | + - name: Create a Release |
| 86 | + uses: ncipollo/release-action@v1 |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + with: |
| 90 | + name: ${{ env.VERSION }} |
| 91 | + tag: ${{ env.VERSION }} |
| 92 | + body: ${{ steps.changelog.outputs.changelog }} |
| 93 | + - name: Publish Test Results |
| 94 | + uses: EnricoMi/publish-unit-test-result-action/composite@v2 |
| 95 | + if: always() |
| 96 | + with: |
| 97 | + comment_mode: failures |
| 98 | + junit_files: | |
| 99 | + **/build/outputs/*-results/**/*.xml |
| 100 | + **/build/*-results/**/*.xml |
0 commit comments