Skip to content

release: Add job to publish to crates.io#43972

Merged
jschwe merged 4 commits into
servo:mainfrom
jschwe:release-publish-crates-io
Apr 10, 2026
Merged

release: Add job to publish to crates.io#43972
jschwe merged 4 commits into
servo:mainfrom
jschwe:release-publish-crates-io

Conversation

@jschwe

@jschwe jschwe commented Apr 6, 2026

Copy link
Copy Markdown
Member

When triggering the release action on a non-protected branch in this repo, the job is rejected (as intended):
image

When triggering the action on a protected branch in this repository, the publish-crates-io job will be pending, until explicitly approved by one of the required approvers (thanks to the environment settings).
This allows us to publish all of our packages in one go.

Testing: Tested by manually triggering a release for 0.1.0-rc2, which got successfully published to crates.io. This was also a resume-after-cancellation test, since the first ~30 crates of the release had already been published via cargo publish --workspace, before running into the issue that cargo publish --workspace can't resume after intermediate failures. The last commit "Fix buffering issue in CI" is untested, and was added after observing the stdout log messages only appearing at the end of the script. That commit is trivial though, and probably does not justify using crates.io resources for another test release.

@jschwe

jschwe commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

It looks like we would indeed need to implement our own wrapper around cargo publish (or vet one of the existing third-party crates), since cargo publish --workspace is too unreliable for our needs, since you currently can't rerun it (cargo issue #13397), when there is an intermediate failure (which can be e.g. a network error). Since we have 60+ crates, we need something more reliable and hence would need a script which checks

  • determine a publish order (I don't think there is a way to let cargo publish --workspace spit that out, so we'll need to reimplement that too)
  • is the crate version already published (if yes, then skip)
  • run cargo publish for each crate

github-merge-queue Bot pushed a commit that referenced this pull request Apr 8, 2026
This is a PR to test the changes from #43972. Publishing happens on a
protected branch, so we need to merge the changes to the protected
branch (crates-io-release-testing) first, in order to test that the
script here works.

-------------

Add a no dependencies python script (besides cargo metadata), to work
around current limitations of `cargo publish --workspace` (which can't
resume publishing after an error). We could also use 3rd party solutions
like cargo workspaces or cargo release, but that would require auditing
their source code, and hence writing a small self-contained script for
our use seems preferable. Hopefully `cargo publish --workspace` will
become more useful in the future, allowing us to eliminate the script
again.

Testing: This will be tested after merging to the feature branch.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
jschwe added 3 commits April 8, 2026 08:31
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Add a no dependencies python script (besides cargo metadata), to work
around current limitations of cargo publish --workspace.
We could also use 3rd party solutions like cargo workspaces or
cargo release, but that would require auditing their source code,
and hence writing a small self-contained script for our use seems
preferable. Hopefully `cargo publish --workspace` will become more
useful in the future, allowing us to eliminate the script again.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
python stdout is apparently block-buffered by default when writing to
files, which is what Github actions apparently appears like.
Let's avoid this by using a log helper, printing to stderr and also
flushing for good measure.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
@jschwe jschwe force-pushed the release-publish-crates-io branch from 98c7996 to 3f5c529 Compare April 8, 2026 06:31
@jschwe jschwe marked this pull request as ready for review April 8, 2026 06:49
@jschwe jschwe requested a review from sagudev as a code owner April 8, 2026 06:49
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 8, 2026
@jschwe jschwe requested a review from mukilan April 10, 2026 06:37

@mukilan mukilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but perhaps someone an admin who has published to crates.io previously and has access to the github environments configuration should also review this to make sure the environment correctly configured e.g, restricted to the release branches.

help="Pass --no-verify to cargo publish.",
)
parser.add_argument(
"--dry-run",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this intentionally not exposed as an input for the release workflow?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is mainly for local debugging of this script (to look at the order the crates will be published in and verify that it makes sense).
In the release workflow I don't see a use-case, we could also just run cargo publish --workspace --dry-run directly if we wanted to verify everything compiles, but for now I chose not to do that, since it takes very long time locally already, so it probably would take hours in CI.

Comment thread etc/ci/publish_crates_io.py Outdated
Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
@jschwe

jschwe commented Apr 10, 2026

Copy link
Copy Markdown
Member Author

LGTM, but perhaps someone an admin who has published to crates.io previously and has access to the github environments configuration should also review this to make sure the environment correctly configured e.g, restricted to the release branches.

@jdm, since you helped configure the environment, perhaps you could also sign-off.
We still also need to discuss who should have the authority to do a release. I believe we can have 6 people in the list of required approvers, and we can (and should) configure that the person that triggered the release, can't approve.

@jschwe jschwe requested a review from jdm April 10, 2026 08:38

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 10, 2026
@jdm

jdm commented Apr 10, 2026

Copy link
Copy Markdown
Member

I'll seed that list with the current set of administrators and turn off self-review, and we can discuss separately if we want to change that list.

@jschwe jschwe added this pull request to the merge queue Apr 10, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 10, 2026
Merged via the queue into servo:main with commit c3d2df2 Apr 10, 2026
30 checks passed
@jschwe jschwe deleted the release-publish-crates-io branch April 10, 2026 18:14
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 10, 2026
jschwe added a commit to jschwe/servo that referenced this pull request Apr 10, 2026
When triggering the release action on a non-protected branch in this
repo, the job is rejected (as intended):
<img width="1484" height="304" alt="image"
src="https://github.com/user-attachments/assets/236d3a41-2765-4652-8709-93110e03c77b"
/>

When triggering the action on a protected branch in this repository, the
publish-crates-io job will be pending, until explicitly approved by one
of the required approvers (thanks to the `environment` settings).
This allows us to publish all of our packages in one go.

Testing: Tested by manually
[triggering](https://github.com/servo/servo/actions/runs/24119955943/job/70371705395)
a release for `0.1.0-rc2`, which got successfully published to
crates.io. This was also a resume-after-cancellation test, since the
first ~30 crates of the release had already been published via `cargo
publish --workspace`, before running into the issue that `cargo publish
--workspace` can't resume after intermediate failures. The last commit
"Fix buffering issue in CI" is untested, and was added after observing
the stdout log messages only appearing at the end of the script. That
commit is trivial though, and probably does not justify using crates.io
resources for another test release.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
(cherry picked from commit c3d2df2)
jschwe added a commit that referenced this pull request Apr 10, 2026
This applies #43972 to the release/v0.1 branch in preparation for the
release.

When triggering the release action on a non-protected branch in this
repo, the job is rejected (as intended):
<img width="1484" height="304" alt="image"

src="https://github.com/user-attachments/assets/236d3a41-2765-4652-8709-93110e03c77b"
/>

When triggering the action on a protected branch in this repository, the
publish-crates-io job will be pending, until explicitly approved by one
of the required approvers (thanks to the `environment` settings). This
allows us to publish all of our packages in one go.

Testing: Tested by manually

[triggering](https://github.com/servo/servo/actions/runs/24119955943/job/70371705395)
a release for `0.1.0-rc2`, which got successfully published to
crates.io. This was also a resume-after-cancellation test, since the
first ~30 crates of the release had already been published via `cargo
publish --workspace`, before running into the issue that `cargo publish
--workspace` can't resume after intermediate failures. The last commit
"Fix buffering issue in CI" is untested, and was added after observing
the stdout log messages only appearing at the end of the script. That
commit is trivial though, and probably does not justify using crates.io
resources for another test release.

---------




(cherry picked from commit c3d2df2)

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants