Skip to content
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Workflow to publish crates.io and GitHub releases
# Changes to this workflow must be reviewed carefully!
name: Publish

# Workflow triggers should be strictly controlled,
# as this will trigger publishing to crates.io.
# We only want to publish on the main branch.
on:
push:
branches: [main]
Expand Down Expand Up @@ -50,3 +55,32 @@ jobs:
with:
release-tag: ${{ needs.publish-github-release.outputs.release-tag }}
rust_version: stable

# Our CI testing ensures that mozjs-sys and mozjs are always bumped together.
# We always publish both versions, since mozjs depends on a specific version
# of mozjs-sys
publish-crates-io:
name: Publish to crates.io
runs-on: ubuntu-latest
needs:
- publish-github-release
- verify-release
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
- uses: rust-lang/crates-io-auth-action@v1
id: auth
# publish mozjs-sys. We ignore the error if the version is already published, but abort the workflow
# on other errors.
- run: |
cargo publish -p mozjs-sys 2> err.log || grep "already exists on crates.io" err.log || ( cat err.log ; exit 1)
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
# Wait a bit to ensure the release is published
- run: sleep 5
- run: |
rm -f err.log
cargo publish -p mozjs 2> err.log || grep "already exists on crates.io" err.log || ( cat err.log ; exit 1)
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
Loading