|
34 | 34 | default: false |
35 | 35 |
|
36 | 36 | permissions: |
37 | | - contents: write |
38 | | - id-token: write |
| 37 | + contents: write # push the release tag and the version-bump branch |
| 38 | + id-token: write # OIDC for the Maven Central release role |
| 39 | + pull-requests: write # open the post-release version-bump PR into main |
39 | 40 |
|
40 | 41 | # Serialize all releases repo-wide to avoid concurrent pushes racing on the |
41 | 42 | # default branch. Never cancel in-flight: it could leave a half-published state. |
@@ -251,10 +252,26 @@ jobs: |
251 | 252 | -Darguments="-gs $MAVEN_SETTINGS -Prelease -Dgpg.keyname=$GPG_KEYNAME -Dgpg.passphrase=$GPG_PASSPHRASE" \ |
252 | 253 | --file "$MODULE/pom.xml" |
253 | 254 |
|
254 | | - # Push commits + tag atomically, only after publish succeeded. |
255 | | - git push --atomic origin \ |
256 | | - "HEAD:${GITHUB_REF_NAME}" \ |
257 | | - "refs/tags/${MODULE}-${EFFECTIVE_RELEASE_VERSION}" |
| 255 | + # main is protected (no direct push), so push the tag and open a PR for |
| 256 | + # the version-bump commits instead. Skipping this would leave the POM on |
| 257 | + # the just-released -SNAPSHOT. |
| 258 | + - name: Push release tag and open version-bump PR |
| 259 | + if: ${{ github.event.inputs.skip_publish != 'true' }} |
| 260 | + env: |
| 261 | + GH_TOKEN: ${{ github.token }} |
| 262 | + run: | |
| 263 | + TAG="${MODULE}-${EFFECTIVE_RELEASE_VERSION}" |
| 264 | + RELEASE_BRANCH="release/${TAG}" |
| 265 | +
|
| 266 | + # Tag push isn't gated by branch protection; commits go via a PR. |
| 267 | + git push origin "refs/tags/${TAG}" |
| 268 | + git push origin "HEAD:refs/heads/${RELEASE_BRANCH}" |
| 269 | +
|
| 270 | + gh pr create \ |
| 271 | + --base "${GITHUB_REF_NAME}" \ |
| 272 | + --head "${RELEASE_BRANCH}" \ |
| 273 | + --title "chore(release): ${MODULE} ${EFFECTIVE_RELEASE_VERSION}" \ |
| 274 | + --body "Post-release version bump for ${MODULE} ${EFFECTIVE_RELEASE_VERSION} (already on Maven Central, tag ${TAG} pushed)." |
258 | 275 |
|
259 | 276 | - name: Dry-run release (prepare only, no publish) |
260 | 277 | if: ${{ github.event.inputs.skip_publish == 'true' }} |
|
0 commit comments