|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + # Trigger only when a release is published |
| 6 | + # Use 'created' if you want it to run as soon as the release draft/tag is made |
| 7 | + # Use 'prereleased' if you want to include pre-releases |
| 8 | + types: [published] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + if: github.event.release.target_commitish == 'main' |
| 16 | + |
| 17 | + permissions: # <--- ADD THIS SECTION |
| 18 | + contents: read |
| 19 | + packages: write # <--- Grants permission to write packages |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Set up JDK 17 |
| 28 | + uses: actions/setup-java@v3 |
| 29 | + with: |
| 30 | + java-version: '17' |
| 31 | + distribution: 'temurin' |
| 32 | + |
| 33 | + - name: Grant execute permission for gradlew |
| 34 | + run: chmod +x gradlew |
| 35 | + |
| 36 | + - name: Install GitVersion |
| 37 | + uses: gittools/actions/gitversion/setup@v3.2.0 |
| 38 | + with: |
| 39 | + versionSpec: '6.2.x' |
| 40 | + |
| 41 | + - name: Determine Version |
| 42 | + id: version_step # step id used as reference for output values |
| 43 | + uses: gittools/actions/gitversion/execute@v3.2.0 |
| 44 | + with: |
| 45 | + useConfigFile: true |
| 46 | + configFilePath: gitversion.yml |
| 47 | + |
| 48 | + - name: Set version in Gradle build file |
| 49 | + run: ./gradlew -Pversion=${{ steps.version_step.outputs.SemVer }} |
| 50 | + |
| 51 | + - name: Build with Gradle |
| 52 | + run: ./gradlew :lib:assemble |
| 53 | + |
| 54 | + - name: Run JVM tests |
| 55 | + run: ./gradlew :lib:jvmTest --info |
| 56 | + continue-on-error: false |
| 57 | + |
| 58 | + - name: Run Android Release tests |
| 59 | + run: ./gradlew :lib:testReleaseUnitTest --info |
| 60 | + continue-on-error: false |
| 61 | + |
| 62 | + - name: Upload Test Report |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: test-results |
| 66 | + path: lib/build/test-results |
| 67 | + |
| 68 | + - name: Upload artifacts |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: build-artifacts-${{ steps.version_step.outputs.SemVer }} |
| 72 | + path: | |
| 73 | + lib/build/libs/*.jar |
| 74 | + lib/build/outputs/aar/*.aar |
| 75 | +
|
| 76 | + - name: Set up GitHub Packages repository |
| 77 | + run: | |
| 78 | + mkdir -p ~/.m2 |
| 79 | + cp .github/settings.xml ~/.m2/settings.xml |
| 80 | +
|
| 81 | + - name: Publish to GitHub Packages |
| 82 | + if: github.event_name != 'pull_request' |
| 83 | + run: ./gradlew publishAllPublicationsToGitHubPackagesRepository --no-configuration-cache -Pversion=${{ steps.version_step.outputs.SemVer }} |
| 84 | + env: |
| 85 | + GITHUB_USERNAME: ${{ secrets.GITHUB_ACTOR }} |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }} |
| 88 | + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }} |
| 89 | + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASS }} |
| 90 | + |
| 91 | + - name: Publish to Maven Central Packages |
| 92 | + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache -Pversion=${{ steps.version_step.outputs.SemVer }} |
| 93 | + env: |
| 94 | + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} |
| 95 | + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} |
| 96 | + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }} |
| 97 | + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }} |
| 98 | + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASS }} |
0 commit comments