Skip to content

Commit 644db5f

Browse files
authored
Issue #160 make release Central deploy idempotent
Closes #160
1 parent e7a0db3 commit 644db5f

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/release-on-tag.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,35 @@ jobs:
6363
See [jdt2jar/README.md](https://github.com/${{ github.repository }}/blob/main/jdt2jar/README.md) for usage.
6464
6565
- name: Build and Deploy to Central (release profile)
66+
id: deploy
6667
env:
6768
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
6869
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
6970
run: |
7071
KN="${{ secrets.GPG_KEYNAME }}"
7172
EXTRA=""
7273
if [ -n "$KN" ]; then EXTRA="-Dgpg.keyname=$KN"; fi
73-
mvn -B -ntp -P release \
74+
if mvn -B -ntp -P release \
7475
-Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" \
7576
$EXTRA \
76-
clean deploy
77+
clean deploy; then
78+
echo "Central deploy succeeded (fresh publish)."
79+
else
80+
# Idempotency guard (issue #160): a deployment of this exact
81+
# version may already be live on Maven Central (e.g. after a
82+
# re-tag). Maven Central versions are immutable; "already
83+
# exists" means the release is live, so treat it as success.
84+
V="${{ steps.version.outputs.version }}"
85+
if curl -fsSL -o /dev/null \
86+
"https://repo1.maven.org/maven2/io/github/simbo1905/json/parent/${V}/parent-${V}.pom" \
87+
&& curl -fsSL -o /dev/null \
88+
"https://repo1.maven.org/maven2/io/github/simbo1905/json/java.util.json/${V}/java.util.json-${V}.pom"; then
89+
echo "Artifacts for ${V} are already live on Maven Central; treating duplicate-publish as success." | tee -a "$GITHUB_STEP_SUMMARY"
90+
else
91+
echo "Central deploy failed and artifacts for ${V} are NOT live on Maven Central." | tee -a "$GITHUB_STEP_SUMMARY"
92+
exit 1
93+
fi
94+
fi
7795
7896
- name: Configure Git identity
7997
run: |

0 commit comments

Comments
 (0)