Skip to content

Commit a91e164

Browse files
Merge pull request #112 from bernardladenthin/claude/stoic-franklin-67klln
Add manual publish control to CI workflow
2 parents 8b792bd + a44fe1f commit a91e164

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
tags: ['v*']
1010
pull_request:
1111
workflow_dispatch:
12+
inputs:
13+
publish_to_central:
14+
description: "Deploy to Maven Central (snapshot if -SNAPSHOT, release if a vX.Y.Z tag)"
15+
type: boolean
16+
default: false
1217

1318
permissions:
1419
contents: read
@@ -197,7 +202,7 @@ jobs:
197202
publish-snapshot:
198203
name: Publish Snapshot to Central
199204
needs: [check-snapshot, code-style]
200-
if: needs.check-snapshot.result == 'success'
205+
if: needs.check-snapshot.result == 'success' && inputs.publish_to_central
201206
runs-on: ubuntu-latest
202207
environment: maven-central
203208
steps:
@@ -212,6 +217,15 @@ jobs:
212217
server-password: MAVEN_PASSWORD
213218
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
214219
gpg-passphrase: MAVEN_GPG_PASSPHRASE
220+
- name: Guard - require a -SNAPSHOT version
221+
shell: bash
222+
run: |
223+
VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version | tail -n1)
224+
echo "Resolved project version: $VERSION"
225+
case "$VERSION" in
226+
*-SNAPSHOT) echo "OK: -SNAPSHOT version, continuing snapshot deploy." ;;
227+
*) 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 ;;
228+
esac
215229
- name: Deploy snapshot
216230
run: mvn --batch-mode --no-transfer-progress -P release deploy -DskipTests
217231
env:
@@ -257,7 +271,7 @@ jobs:
257271
publish-release:
258272
name: Publish Release to Central
259273
needs: [check-tag, code-style]
260-
if: needs.check-tag.result == 'success'
274+
if: needs.check-tag.result == 'success' && inputs.publish_to_central
261275
runs-on: ubuntu-latest
262276
environment: maven-central
263277
permissions:

0 commit comments

Comments
 (0)