Skip to content

Commit 53204f2

Browse files
committed
ci(publish): abort snapshot publish unless the POM version is a -SNAPSHOT
Add a guard step to the publish-snapshot job that resolves project.version via `mvn help:evaluate` and fails the job unless the version ends in -SNAPSHOT. central-publishing routes purely by version: a release version (no -SNAPSHOT) deployed through the snapshot path lands in the permanent Maven Central release store, not the snapshot store. This guard stops that from ever happening from the snapshot job; releases continue to go through the v* tag path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JGZdUCy6YnTzKSJKA6B6KZ
1 parent cc41470 commit 53204f2

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,15 @@ jobs:
906906
server-password: MAVEN_PASSWORD
907907
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
908908
gpg-passphrase: MAVEN_GPG_PASSPHRASE
909+
- name: Guard - require a -SNAPSHOT version
910+
shell: bash
911+
run: |
912+
VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version | tail -n1)
913+
echo "Resolved project version: $VERSION"
914+
case "$VERSION" in
915+
*-SNAPSHOT) echo "OK: -SNAPSHOT version, continuing snapshot deploy." ;;
916+
*) echo "::error::Refusing to publish non-SNAPSHOT version '$VERSION' from the snapshot job. Snapshot publishing requires a -SNAPSHOT version; releases go through the v* tag path."; exit 1 ;;
917+
esac
909918
- name: Publish snapshot
910919
run: mvn --batch-mode --no-transfer-progress -P release,cuda,opencl-android -Dmaven.test.skip=true deploy
911920
env:

0 commit comments

Comments
 (0)