|
| 1 | +# Copyright 2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: release-please |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: |
| 20 | + - main |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: write |
| 24 | + pull-requests: write |
| 25 | + |
| 26 | +jobs: |
| 27 | + release-please: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: googleapis/release-please-action@v4 |
| 31 | + id: release |
| 32 | + with: |
| 33 | + token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} |
| 34 | + |
| 35 | + # The steps below only run when a release PR is merged and a GitHub release is created |
| 36 | + - name: Checkout |
| 37 | + if: ${{ steps.release.outputs.release_created }} |
| 38 | + uses: actions/checkout@v6 |
| 39 | + |
| 40 | + - name: Set up JDK 17 |
| 41 | + if: ${{ steps.release.outputs.release_created }} |
| 42 | + uses: actions/setup-java@v5 |
| 43 | + with: |
| 44 | + java-version: '17' |
| 45 | + distribution: 'temurin' |
| 46 | + |
| 47 | + - uses: gradle/actions/setup-gradle@v4 |
| 48 | + if: ${{ steps.release.outputs.release_created }} |
| 49 | + |
| 50 | + - name: Set up Gradle Publishing Environment Variables |
| 51 | + if: ${{ steps.release.outputs.release_created }} |
| 52 | + run: | |
| 53 | + echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc |
| 54 | + gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc |
| 55 | +
|
| 56 | + echo "Build and publish" |
| 57 | + sed -i -e "s,mavenCentralUsername=,mavenCentralUsername=$SONATYPE_TOKEN_USERNAME,g" gradle.properties |
| 58 | + SONATYPE_TOKEN_PASSWORD_ESCAPED=$(printf '%s\n' "$SONATYPE_TOKEN_PASSWORD" | sed -e 's/[\/&]/\\&/g') |
| 59 | + sed -i -e "s,mavenCentralPassword=,mavenCentralPassword=$SONATYPE_TOKEN_PASSWORD_ESCAPED,g" gradle.properties |
| 60 | + sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties |
| 61 | + sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties |
| 62 | + sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties |
| 63 | + env: |
| 64 | + GPG_KEY_ARMOR: ${{ secrets.SYNCED_GPG_KEY_ARMOR }} |
| 65 | + GPG_KEY_ID: ${{ secrets.SYNCED_GPG_KEY_ID }} |
| 66 | + GPG_PASSWORD: ${{ secrets.SYNCED_GPG_KEY_PASSWORD }} |
| 67 | + SONATYPE_TOKEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN_PASSWORD }} |
| 68 | + SONATYPE_TOKEN_USERNAME: ${{ secrets.SONATYPE_TOKEN }} |
| 69 | + |
| 70 | + - name: Build and Publish |
| 71 | + if: ${{ steps.release.outputs.release_created }} |
| 72 | + run: | |
| 73 | + ./gradlew build --warn --stacktrace |
| 74 | + ./gradlew publishToMavenCentral --warn --stacktrace --debug --info |
| 75 | + env: |
| 76 | + GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} |
0 commit comments