Skip to content

Commit 9684e69

Browse files
committed
release: guard Central the way pub.dev and crates.io are, and let dispatch work
Both fall out of the org-level Maven secrets existing. The Central job used to warn and skip because no signing key was configured; now it will actually run, and its first act on a re-run would be to deploy a version Central already has, which Central never allows. It now asks first, like the other two registries. `workflow_dispatch` was in `on:` as the way back from a tag whose event was never delivered, but `verify` read the version from `${GITHUB_REF_NAME#v}` — on a manual run that is the branch, so it computed `main` and failed the manifest check. It now falls back to the core's own version, which is the reference `check_versions.sh` already uses when called without an argument. Checked against Central: 0.1.0 reports as present and skips, an absent version falls through to the deploy.
1 parent bc1f6a9 commit 9684e69

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,17 @@ jobs:
4646
- id: check
4747
shell: bash
4848
run: |
49-
version="${GITHUB_REF_NAME#v}"
49+
# `workflow_dispatch` is in `on:` as the way back from a tag whose
50+
# event was never delivered, and it has no tag to read. Fall back to
51+
# the core's own version, which is the reference `check_versions.sh`
52+
# uses when it is called without an argument.
53+
if [ "${GITHUB_REF_TYPE:-}" = tag ]; then
54+
version="${GITHUB_REF_NAME#v}"
55+
else
56+
version="$(sed -n 's/^version: *//p' \
57+
dart/dbinspect_bridge/pubspec.yaml | head -1)"
58+
echo "::notice::not a tag, releasing the manifest version $version"
59+
fi
5060
tool/check_versions.sh "$version"
5161
echo "version=$version" >> "$GITHUB_OUTPUT"
5262
@@ -157,8 +167,25 @@ jobs:
157167
printf '%s' "$MAVEN_GPG_PRIVATE_KEY" | gpg --batch --import
158168
echo "ready=true" >> "$GITHUB_OUTPUT"
159169
170+
# Central never lets a version be replaced, so a re-run — or a release
171+
# resumed after one registry failed — must not attempt one that is up.
172+
# The same rule the pub.dev and crates.io jobs follow.
173+
- name: Is it already on Central?
174+
id: central
175+
env:
176+
VERSION: ${{ needs.verify.outputs.version }}
177+
run: |
178+
set -euo pipefail
179+
base=https://repo1.maven.org/maven2/org/dizitart/dbinspect-bridge
180+
if curl -sfo /dev/null "$base/$VERSION/dbinspect-bridge-$VERSION.pom"; then
181+
echo "dbinspect-bridge $VERSION is already on Maven Central"
182+
echo "skip=true" >> "$GITHUB_OUTPUT"
183+
else
184+
echo "skip=false" >> "$GITHUB_OUTPUT"
185+
fi
186+
160187
- name: Set the release version
161-
if: steps.gpg.outputs.ready == 'true'
188+
if: steps.gpg.outputs.ready == 'true' && steps.central.outputs.skip == 'false'
162189
working-directory: jvm/dbinspect-bridge
163190
run: |
164191
mvn -B -ntp org.codehaus.mojo:versions-maven-plugin:2.21.0:set \
@@ -169,7 +196,7 @@ jobs:
169196
# The settings file is written here rather than committed because the two
170197
# values in it are secrets.
171198
- name: Deploy
172-
if: steps.gpg.outputs.ready == 'true'
199+
if: steps.gpg.outputs.ready == 'true' && steps.central.outputs.skip == 'false'
173200
working-directory: jvm/dbinspect-bridge
174201
env:
175202
CENTRAL_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}

0 commit comments

Comments
 (0)