Skip to content

Add CI workflow to publish backtrace after a push to main - #165802

Merged
rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
Kobzol:publish-crates
Nov 20, 2026
Merged

rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
Kobzol:publish-crates

Conversation

@Kobzol

@Kobzol Kobzol commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

View all comments

This PR implements crate publishing, which is required for rust-lang/backtrace-rs#778, and would be useful also for other use-cases in the future.
To keep things simple, I reused the existing post-merge workflow, and implemented the publishing in bash.

To make this work, we will also need to make changes in team: rust-lang/team#2941

I think that we could start by moving the publishing to rust-lang/rust, while still keeping the submodule, and test whether the publishing works as expected. Then we can get rid of the submodule and inline backtrace into rust-lang/rust.

CC @workingjubilee

I used a chatbot to generate the if condition line in bash (lol), and the cargo metadata command.

r? jieyouxu

@rustbot rustbot added A-CI Area: Our Github Actions CI S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Nov 11, 2026
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
@Kobzol

Kobzol commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Set the environment variables and updated the message.

Comment thread .github/workflows/post-merge.yml Outdated

gh pr comment ${HEAD_PR} -F output.log
else
echo "Nothing was published. Either there is no version update or some error has occurred."

@marcoieni marcoieni Nov 11, 2026 •

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.

If errors occur, the CI workflow is green. Will anyone notice and fix the issue?

My preference would be to catch these errors and fail the workflow, but I leave the choice to the author and the reviewer of this PR the final saying. 👍

View changes since the review

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.

Perhaps it's worth doing cargo publish --dry-run as part of PR CI? That probably catches the most likely failures, other than transients.

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.

Does that do something more interesting other than just building the crate (which we should do as a part of our normal CI)?

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.

Don't quote me on this but I believe it packages a .crate and attempts to build from that, which catches things like incorrect include/exclude in the manifest

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.

Should we comment on the PR if the publish failed for a reason other than whatever the "already published" message is?

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.

Don't quote me on this but I believe it packages a .crate and attempts to build from that, which catches things like incorrect include/exclude in the manifest

AFAIK this sounds about right (https://doc.rust-lang.org/cargo/commands/cargo-publish.html#publish-options is a bit light on specifics). In particular it'd check Cargo.toml manifest. (Also use cargo published --locked --dry-run.)

We might want to also cargo package --locked --list to list all the files that goes to the final published artifact eventually.

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.

My preference would be to catch these errors and fail the workflow

I share this sentiment, IMO we should fail hard here.

@workingjubilee workingjubilee self-assigned this Nov 11, 2026
@workingjubilee

Copy link
Copy Markdown
Member

Making sure I review this soonish, probably still want our friendly local proto for the actual CI code.

@workingjubilee

Copy link
Copy Markdown
Member

I used a chatbot to generate the if condition line in bash (lol), and the cargo metadata command.

asked the things that produce inscrutable code for inscrutable code. fair play.

@jieyouxu jieyouxu 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.

Some things

(Disclaimer: reviewed myself first, then also reviewed again with an LLM because GHA + bash is a recipe for hard-to-notice bugs 😓)

View changes since this review

Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Outdated

gh pr comment ${HEAD_PR} -F output.log
else
echo "Nothing was published. Either there is no version update or some error has occurred."

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.

My preference would be to catch these errors and fail the workflow

I share this sentiment, IMO we should fail hard here.

Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
Comment thread .github/workflows/post-merge.yml Resolved
@Kobzol

Kobzol commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

I'm not sure how to reliably detect whether the publish failed because the version is already published, or because of something else. Both seems to return exit code 101.

@Kobzol

Kobzol commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

I guess that we could either:

  1. Check whether the version exists on crates.io
  2. Parse the stderr of Cargo if it fails, and pattern match an error that says the version already exists
  3. Do --dry-run, and if that succeeds, but the follow-up upload fails, then treat that as a duplicate version. But that could still skip and not report invalid uploads that didn't happen.

@jieyouxu

Copy link
Copy Markdown
Member

I guess that we could either:

  1. Check whether the version exists on crates.io
  2. Parse the stderr of Cargo if it fails, and pattern match an error that says the version already exists
  3. Do --dry-run, and if that succeeds, but the follow-up upload fails, then treat that as a duplicate version. But that could still skip and not report invalid uploads that didn't happen.

Hm... I feel like (1) might be worth trying. (2) is essentially fragile to unstable cargo wording, (3) seems to swallow the errors we care about anyway...

@Kobzol

Kobzol commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Ok, added the check.

@workingjubilee

Copy link
Copy Markdown
Member

In particular my desire would be

"I would prefer my PR is not automatically closed by GH's process if it has not actually gone off and published the crate."

Even if that means something wildly unintuitive! I would be fine if I have to manually check and confirm that an "error" in the workflow is Actually Success, then close my own PR. I'm good with that.

It seems we're trying to do something more clever than that, which is fine as long as the item doesn't leave "my desk" (open PRs) before it Actually Succeeds.

@workingjubilee

Copy link
Copy Markdown
Member

I could make the adjustment of checking "already-merged" PRs more and more often than I already do, but I don't want to increase the neuroticism of my interactions with GitHub, for everyone's sake.

@workingjubilee workingjubilee 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.

honestly my eyes glazed over a bit reading "bash-in-yaml"... I actually consider myself bash-proficient but for some reason this embedding just throws me, is it really just the lack of syntax highlighting or something...? ...but to the extent I understand this it seems good.

View changes since this review

Comment thread .github/workflows/post-merge.yml Outdated
Comment on lines +107 to +112
echo "backtrace \`${VERSION}\` could not be published to crates.io" > comment.txt
printf "<details>\n<summary>Cargo publish log</summary>\n\n" >> comment.txt
printf '```\n' >> comment.txt
cat "${RUNNER_TEMP}/cargo-log.txt" >> comment.txt
printf '\n```\n' >> comment.txt
printf "</details>\n\n" >> comment.txt

@workingjubilee workingjubilee Nov 13, 2026 •

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.

me, to me: "could this be replaced by a heredoc?"
me, to me: "would that actually make it more legible?"
me, to me: "uhmmm... lol?"

View changes since the review

@Kobzol

Kobzol commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

We could move the publish from the post-merge workflow to the main CI workflow, near the publish toolstate step. Of course the danger there is that if publishing fails (even spuriously), it will cancel the whole bors merge.

@jieyouxu

Copy link
Copy Markdown
Member

Hm. Technically we could say, if stdarch needs publishing it should rollup=never so if it fails main CI it's fine?

@Kobzol

Kobzol commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

I don't follow what would be the difference between the thing being rolled up or not 🤔 "it's fine", as in, at least it won't cancel the merge of other PRs?

@jieyouxu

jieyouxu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Yeah. But probably doesn't matter though, was just thinking.

@rust-log-analyzer

This comment has been minimized.

@workingjubilee workingjubilee 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.

Thanks!

Typos that are barely relevant.

My current mood is that we ship this, try it out for a backtrace release, and then I will have feedback on possible adjustments from practical experience.

View changes since this review

Comment thread src/ci/publish_backtrace.sh Resolved
Comment thread src/ci/publish_backtrace.sh Resolved
Co-authored-by: Jubilee <[email protected]>
@Kobzol

Kobzol commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Yeah, I would be very surprised if this works on the first try. I'd suggest merging this, then merging rust-lang/team#2941, and then trying to do a release from this PR (will need a backtrace submodule sync).

@workingjubilee

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 64b54df has been approved by workingjubilee

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 19, 2026
@workingjubilee

Copy link
Copy Markdown
Member

@bors r-

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 19, 2026
@rust-bors

rust-bors Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

@workingjubilee

Copy link
Copy Markdown
Member

@bors r=workingjubilee,jieyouxu

@rust-bors

rust-bors Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 64b54df has been approved by workingjubilee,jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 19, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 20, 2026
…bilee,jieyouxu

Add CI workflow to publish backtrace after a push to main

This PR implements crate publishing, which is required for rust-lang/backtrace-rs#778, and would be useful also for other use-cases in the future.
To keep things simple, I reused the existing post-merge workflow, and implemented the publishing in bash.

To make this work, we will also need to make changes in team: rust-lang/team#2941

I think that we could start by moving the publishing to `rust-lang/rust`, while still keeping the submodule, and test whether the publishing works as expected. Then we can get rid of the submodule and inline `backtrace` into `rust-lang/rust`.

CC @workingjubilee

I used a chatbot to generate the if condition line in bash (lol), and the `cargo metadata` command.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Nov 20, 2026
Rollup of 21 pull requests

Successful merges:

 - #165707 (bootstrap: Make low priority the default)
 - #165716 (Refactor split_block in check_pointers to avoid Terminator: None)
 - #165934 (Avoid using Terminator:None in simplify_cfg)
 - #166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`)
 - #166069 (bootstrap: fix keep-stage-std)
 - #166117 (Remove ebadf handling from stdio)
 - #166119 (Avoid an ICE on re-exports of private imports without a DefId)
 - #165094 (reflection: doc attributes from adts, fields, and variants)
 - #165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected)
 - #165694 (view-types: make sure view types are !Sized)
 - #165802 (Add CI workflow to publish backtrace after a push to main)
 - #165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector)
 - #165906 (fix ICE when a forced keyword follows a parameter pattern)
 - #166064 (Add const generic transmute min support)
 - #166136 (Move ub_checks() inside the const_eval_select branch.)
 - #166158 (bump some tools' `toml` dependency)
 - #166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`)
 - #166176 (compiletest: Move all code out of the crate root)
 - #166185 (simd-test: Fix cfg syntax in the test macro)
 - #166194 (std: Unstably constify `std::process::abort`)
 - #166210 (Avoid terminator: None in insert_direct_enum_check)

Failed merges:

 - #166150 (Reflection: refactor Type and TypeKind)
 - #166160 (refactor CTFE-specific intrinsics to different file)
rust-bors Bot pushed a commit that referenced this pull request Nov 20, 2026
Rollup of 20 pull requests

Successful merges:

 - #165716 (Refactor split_block in check_pointers to avoid Terminator: None)
 - #165934 (Avoid using Terminator:None in simplify_cfg)
 - #166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`)
 - #166069 (bootstrap: fix keep-stage-std)
 - #166117 (Remove ebadf handling from stdio)
 - #166119 (Avoid an ICE on re-exports of private imports without a DefId)
 - #165094 (reflection: doc attributes from adts, fields, and variants)
 - #165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected)
 - #165694 (view-types: make sure view types are !Sized)
 - #165802 (Add CI workflow to publish backtrace after a push to main)
 - #165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector)
 - #165906 (fix ICE when a forced keyword follows a parameter pattern)
 - #166064 (Add const generic transmute min support)
 - #166136 (Move ub_checks() inside the const_eval_select branch.)
 - #166158 (bump some tools' `toml` dependency)
 - #166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`)
 - #166176 (compiletest: Move all code out of the crate root)
 - #166185 (simd-test: Fix cfg syntax in the test macro)
 - #166194 (std: Unstably constify `std::process::abort`)
 - #166210 (Avoid terminator: None in insert_direct_enum_check)

Failed merges:

 - #166150 (Reflection: refactor Type and TypeKind)
 - #166160 (refactor CTFE-specific intrinsics to different file)
@tgross35

Copy link
Copy Markdown
Member

If #166230 happens to fail then could this get some history cleanup / squash?

@rust-bors
rust-bors Bot merged commit 91acc98 into rust-lang:main Nov 20, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 20, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 20, 2026
Rollup merge of #165802 - Kobzol:publish-crates, r=workingjubilee,jieyouxu

Add CI workflow to publish backtrace after a push to main

This PR implements crate publishing, which is required for rust-lang/backtrace-rs#778, and would be useful also for other use-cases in the future.
To keep things simple, I reused the existing post-merge workflow, and implemented the publishing in bash.

To make this work, we will also need to make changes in team: rust-lang/team#2941

I think that we could start by moving the publishing to `rust-lang/rust`, while still keeping the submodule, and test whether the publishing works as expected. Then we can get rid of the submodule and inline `backtrace` into `rust-lang/rust`.

CC @workingjubilee

I used a chatbot to generate the if condition line in bash (lol), and the `cargo metadata` command.

r? jieyouxu
@Kobzol
Kobzol deleted the publish-crates branch November 20, 2026 09:46
folkertdev pushed a commit to folkertdev/stdarch that referenced this pull request Nov 22, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#165716 (Refactor split_block in check_pointers to avoid Terminator: None)
 - rust-lang/rust#165934 (Avoid using Terminator:None in simplify_cfg)
 - rust-lang/rust#166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`)
 - rust-lang/rust#166069 (bootstrap: fix keep-stage-std)
 - rust-lang/rust#166117 (Remove ebadf handling from stdio)
 - rust-lang/rust#166119 (Avoid an ICE on re-exports of private imports without a DefId)
 - rust-lang/rust#165094 (reflection: doc attributes from adts, fields, and variants)
 - rust-lang/rust#165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected)
 - rust-lang/rust#165694 (view-types: make sure view types are !Sized)
 - rust-lang/rust#165802 (Add CI workflow to publish backtrace after a push to main)
 - rust-lang/rust#165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector)
 - rust-lang/rust#165906 (fix ICE when a forced keyword follows a parameter pattern)
 - rust-lang/rust#166064 (Add const generic transmute min support)
 - rust-lang/rust#166136 (Move ub_checks() inside the const_eval_select branch.)
 - rust-lang/rust#166158 (bump some tools' `toml` dependency)
 - rust-lang/rust#166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`)
 - rust-lang/rust#166176 (compiletest: Move all code out of the crate root)
 - rust-lang/rust#166185 (simd-test: Fix cfg syntax in the test macro)
 - rust-lang/rust#166194 (std: Unstably constify `std::process::abort`)
 - rust-lang/rust#166210 (Avoid terminator: None in insert_direct_enum_check)

Failed merges:

 - rust-lang/rust#166150 (Reflection: refactor Type and TypeKind)
 - rust-lang/rust#166160 (refactor CTFE-specific intrinsics to different file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants