-
Notifications
You must be signed in to change notification settings - Fork 327
Sync crates.io Trusted Publishing configs #2078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
If you are changing the data structures, please make sure that the changes are not going to break serde deserialization (adding a field is fine; removing or renaming a field isn't). If you must do a breaking change to the format, make sure to coordinate it with all the users of the cc @Urgau |
|
Actually, given that we might want to have a first-class support for crates in team DB (rust-lang/infra-team#204 (comment)), I will refactor the schema slightly to make it more future-compatible. |
might be worth mentioning that this is a restriction on the |
Dry-run check results |
pietroalbini
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, left some general feedback.
docs/toml-schema.md
Outdated
| Configure crates.io Trusted Publishing for crates published from a given repository from GitHub Actions. | ||
|
|
||
| ```toml | ||
| [[trusted-publishing]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd call it crates-io-publishing, if in the future we need to integrate with other ecosystems.
| # Name of a GitHub Actions workflow file that will publish the crate (required) | ||
| workflow-filename = "ci.yml" | ||
| # GitHub Actions environment that has to be used for the publishing (optional) | ||
| environment = "deploy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally enforce on the sync-team side that an environment is always configured when publishing. I don't see any case when we would want all workflows on a repository to publish crates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might make it a bit harder to deploy TP though, as creating an environment will require an infra-admin for each repo? Or are they auto-created if you just specify them in the YML workflow file? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not auto-created :(
| # Name of a GitHub Actions workflow file that will publish the crate (required) | ||
| workflow-filename = "ci.yml" | ||
| # GitHub Actions environment that has to be used for the publishing (optional) | ||
| environment = "deploy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only people with maintain+ access on a repo can create environments. We'd need a way to let people create environments without infra-admins involvement. Also, migrating all environments to be managed by the team repo might not be trivial, as a lot of environments nowadays are created by Terraform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, this answers my question above. So what would you prefer? Make environments optional for now? Or make them required and involve infra admins in their creation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better now to require them, and eventually integrate them in the team repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do environments do in this case? Why would they be required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environments can be used to ensure that the publish happens only from a specific branch or workflow job. That is useful to ensure that unexpected parts of CI (e.g. those that execute untrusted code at build time) are not allowed to publish.
Is this zero or one? It would be nice to have a good way to remove those configs (e.g., if we rename a repo or move it out of rust-lang org), otherwise I worry we'd forget and leave behind a possible future risk. Or does crates.io attach them to some GitHub repo id despite the naming convention? I don't think that's a thing.... |
|
It should have said "at most one", I clarified it in the PR description. Before the endpoint for enumerating TP configs is implemented, I don't think that we can reliably remove all stale configs, right? The TP configs are attached to a repository name (org/name). |
And expand that publishing configs into a list of crates in the v1 API.
|
Changed to make environment mandatory and expand the set of TPs into a set of crates in the v1 API. |
This PR adds support for synchronizing Trusted Publishing configurations for crates published from repositories managed by
team.Currently, it works like this:
team, it lists the existing configs.Some additional notes:
teamDB, because the crates.io API does not currently have a way of listing trusted publishing configs for an API token, without knowing the corresponding crate name.teamDB that I think makes sense.I already configured this to run on CI, although we do not have the crates.io token configured for dry-run, that might be nice to add (but I don't think that crates.io allows creating read-only tokens, so we would have to do the dry-runs with a full token).