Skip to content

Commit 46daba6

Browse files
committed
Always attempt to publish, and handle exists error gracefully
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
1 parent c52dc84 commit 46daba6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ jobs:
4242
git fetch --tags --quiet
4343
if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then
4444
gh release create ${RELEASE_TAG} ./*.tar.gz
45-
echo "CREATE_RELEASE=true" >> ${GITHUB_OUTPUT}
46-
else
47-
echo "CREATE_RELEASE=false" >> ${GITHUB_OUTPUT}
4845
fi
4946
echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT}
5047
outputs:
5148
release-tag: ${{ steps.check-tag.outputs.RELEASE_TAG }}
52-
create-release: ${{ steps.check-tag.outputs.CREATE_RELEASE }}
5349

5450
verify-release:
5551
name: Verify release
@@ -71,17 +67,20 @@ jobs:
7167
- verify-release
7268
permissions:
7369
id-token: write
74-
if: ${{ needs.publish-github-release.outputs.create-release }}
7570
steps:
7671
- uses: actions/checkout@v6
7772
- uses: rust-lang/crates-io-auth-action@v1
7873
id: auth
79-
# publish mozjs-sys
80-
- run: cargo publish -p mozjs-sys
74+
# publish mozjs-sys. We ignore the error if the version is already published, but abort the workflow
75+
# on other errors.
76+
- run: |
77+
cargo publish -p mozjs-sys 2> err.log || grep "already exists on crates.io" err.log || ( cat err.log ; exit 1)
8178
env:
8279
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
8380
# Wait a bit to ensure the release is published
8481
- run: sleep 5
85-
- run: cargo publish -p mozjs
82+
- run: |
83+
rm -f err.log
84+
cargo publish -p mozjs 2> err.log || grep "already exists on crates.io" err.log || ( cat err.log ; exit 1)
8685
env:
8786
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

0 commit comments

Comments
 (0)