Skip to content

Commit fad9c70

Browse files
committed
Make it possible to enforce publishing only through trusted publishing for crates
1 parent 92cec71 commit fad9c70

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

docs/toml-schema.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ crates = ["regex"]
456456
workflow-filename = "ci.yml"
457457
# GitHub Actions environment that has to be used for the publishing (required)
458458
environment = "deploy"
459+
# Disable other mechanisms for publishing this set of crates (optional, default is false)
460+
# If set to `true`, the crates will only be publishable through trusted publishing
461+
disable-other-publish-methods = false
459462
```
460463

461464
> [!TIP]

rust_team_data/src/v1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ pub struct Repo {
188188
pub struct Crate {
189189
pub name: String,
190190
pub crates_io_publishing: Option<CratesIoPublishing>,
191+
pub trusted_publishing_only: bool,
191192
}
192193

193194
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]

src/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ pub(crate) struct CratesIoPublishing {
880880
pub crates: Vec<String>,
881881
pub workflow_filename: String,
882882
pub environment: String,
883+
#[serde(default)]
884+
pub disable_other_publish_methods: bool,
883885
}
884886

885887
#[derive(serde_derive::Deserialize, Debug, Clone)]

src/static_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl<'a> Generator<'a> {
157157
workflow_file: p.workflow_filename.clone(),
158158
environment: p.environment.clone(),
159159
}),
160+
trusted_publishing_only: p.disable_other_publish_methods,
160161
})
161162
})
162163
.collect(),

tests/static-api/_expected/v1/repos.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,16 @@
7171
"crates_io_publishing": {
7272
"workflow_file": "ci.yml",
7373
"environment": "deploy"
74-
}
74+
},
75+
"trusted_publishing_only": false
7576
},
7677
{
7778
"name": "my-crate-2",
7879
"crates_io_publishing": {
7980
"workflow_file": "ci.yml",
8081
"environment": "deploy"
81-
}
82+
},
83+
"trusted_publishing_only": false
8284
}
8385
],
8486
"environments": [],

tests/static-api/_expected/v1/repos/some_repo.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@
3939
"crates_io_publishing": {
4040
"workflow_file": "ci.yml",
4141
"environment": "deploy"
42-
}
42+
},
43+
"trusted_publishing_only": false
4344
},
4445
{
4546
"name": "my-crate-2",
4647
"crates_io_publishing": {
4748
"workflow_file": "ci.yml",
4849
"environment": "deploy"
49-
}
50+
},
51+
"trusted_publishing_only": false
5052
}
5153
],
5254
"environments": [],

0 commit comments

Comments
 (0)