Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/workflows/release-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,35 @@ jobs:
See [jdt2jar/README.md](https://github.com/${{ github.repository }}/blob/main/jdt2jar/README.md) for usage.

- name: Build and Deploy to Central (release profile)
id: deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
run: |
KN="${{ secrets.GPG_KEYNAME }}"
EXTRA=""
if [ -n "$KN" ]; then EXTRA="-Dgpg.keyname=$KN"; fi
mvn -B -ntp -P release \
if mvn -B -ntp -P release \
-Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" \
$EXTRA \
clean deploy
clean deploy; then
echo "Central deploy succeeded (fresh publish)."
else
# Idempotency guard (issue #160): a deployment of this exact
# version may already be live on Maven Central (e.g. after a
# re-tag). Maven Central versions are immutable; "already
# exists" means the release is live, so treat it as success.
V="${{ steps.version.outputs.version }}"
if curl -fsSL -o /dev/null \
"https://repo1.maven.org/maven2/io/github/simbo1905/json/parent/${V}/parent-${V}.pom" \
&& curl -fsSL -o /dev/null \
"https://repo1.maven.org/maven2/io/github/simbo1905/json/java.util.json/${V}/java.util.json-${V}.pom"; then
Comment on lines +85 to +88

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject re-tags whose artifacts differ

When a release tag is force-moved after fixes, the original version's POMs can still return HTTP 200 even though the new tag builds different artifacts. Maven then fails because the version is immutable, but this guard treats the old POMs as proof of success, allowing the Docker job to publish the new commit under the same version while Maven Central continues serving the old code. Compare the locally built artifacts with the published checksums, or reject a moved tag rather than checking only coordinate existence.

AGENTS.md reference: AGENTS.md:L332-L335

Useful? React with 👍 / 👎.

echo "Artifacts for ${V} are already live on Maven Central; treating duplicate-publish as success." | tee -a "$GITHUB_STEP_SUMMARY"
else
echo "Central deploy failed and artifacts for ${V} are NOT live on Maven Central." | tee -a "$GITHUB_STEP_SUMMARY"
exit 1
fi
fi

- name: Configure Git identity
run: |
Expand Down
Loading