|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | +# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created |
| 6 | +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle |
| 7 | + |
| 8 | +name: Publish Packages to GitHub Packages with Gradle |
| 9 | + |
| 10 | +on: |
| 11 | + release: |
| 12 | + types: [created] |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build and Publish |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Restore gradle.properties |
| 26 | + env: |
| 27 | + GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }} |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + mkdir -p ~/.gradle/ |
| 31 | + echo "::set-env name=GRADLE_USER_HOME::$HOME/.gradle" |
| 32 | + echo ${GRADLE_PROPERTIES} > ~/.gradle/gradle.properties |
| 33 | +
|
| 34 | + - name: Restore gpg secret ring file |
| 35 | + env: |
| 36 | + GPG_SECRET_KEY_RING: ${{ secrets.GPG_SECRET_KEY_RING }} |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + mkdir -p ~/.gnupg/ |
| 40 | + echo ${GPG_SECRET_KEY_RING} > ~/.gnupg/42CBCB82.gpg |
| 41 | +
|
| 42 | + - name: Set up JDK 17 |
| 43 | + uses: actions/setup-java@v4 |
| 44 | + with: |
| 45 | + java-version: '17' |
| 46 | + distribution: 'corretto' |
| 47 | + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml |
| 48 | + settings-path: ${{ github.workspace }} # location for the settings.xml file |
| 49 | + |
| 50 | + - name: Setup Gradle |
| 51 | + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 |
| 52 | + |
| 53 | + - name: Grant Execution Authority to Gradlew |
| 54 | + run: chmod +x ./gradlew |
| 55 | + |
| 56 | + - name: Build with Gradle |
| 57 | + run: ./gradlew build |
| 58 | + |
| 59 | + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in |
| 60 | + # the publishing section of your build.gradle |
| 61 | + - name: Publish to GitHub Packages |
| 62 | + run: ./gradlew publishAllPublicationsToGithubPackagesRepository -x |
| 63 | + env: |
| 64 | + USERNAME: ${{ github.actor }} |
| 65 | + TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments