Skip to content

Commit fd23b3f

Browse files
committed
fix: publish using docs features
1 parent ad6363a commit fd23b3f

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/main.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ fn discover_crates(dir: &PathBuf, crates: &mut BTreeMap<CrateId, Crate>) -> Resu
143143
let id = parsed.package.name;
144144

145145
let metadata = &parsed.package.metadata.embassy;
146+
let metadata_docs = &parsed.package.metadata.embassy_docs;
146147

147148
if metadata.skip {
148149
continue;
@@ -155,6 +156,7 @@ fn discover_crates(dir: &PathBuf, crates: &mut BTreeMap<CrateId, Crate>) -> Resu
155156
}
156157
}
157158

159+
let docs = metadata_docs.clone();
158160
let mut configs = metadata.build.clone();
159161
if configs.is_empty() {
160162
configs.push(BuildConfig {
@@ -172,6 +174,7 @@ fn discover_crates(dir: &PathBuf, crates: &mut BTreeMap<CrateId, Crate>) -> Resu
172174
path,
173175
dependencies,
174176
configs,
177+
docs,
175178
publish: parsed.package.publish,
176179
},
177180
);
@@ -495,23 +498,18 @@ fn update_changelog(repo: &Path, c: &Crate) -> Result<()> {
495498

496499
fn publish_release(_repo: &Path, c: &Crate, push: bool) -> Result<()> {
497500
// Use the config with the must features!
498-
let mut config = c.configs.first().unwrap();
499-
for c in c.configs.iter() {
500-
if c.features.len() > config.features.len() {
501-
config = c;
502-
}
503-
}
504-
505501
let mut args: Vec<String> = vec![
506502
"publish".to_string(),
507503
"--manifest-path".to_string(),
508504
c.path.join("Cargo.toml").display().to_string(),
509505
];
510506

511-
args.push("--features".into());
512-
args.push(config.features.join(","));
507+
if !c.docs.features.is_empty() {
508+
args.push("--features".into());
509+
args.push(c.docs.features.join(","));
510+
}
513511

514-
if let Some(target) = &config.target {
512+
if let Some(target) = &c.docs.target {
515513
args.push("--target".into());
516514
args.push(target.clone());
517515
}

src/types.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ fn default_publish() -> bool {
2727
pub struct Metadata {
2828
#[serde(default)]
2929
pub embassy: MetadataEmbassy,
30+
#[serde(default)]
31+
pub embassy_docs: MetadataEmbassyDocs,
3032
}
3133

3234
#[allow(dead_code)]
@@ -38,6 +40,14 @@ pub struct MetadataEmbassy {
3840
pub build: Vec<BuildConfig>,
3941
}
4042

43+
#[allow(dead_code)]
44+
#[derive(Clone, Debug, Deserialize, Default)]
45+
pub struct MetadataEmbassyDocs {
46+
#[serde(default)]
47+
pub features: Vec<String>,
48+
pub target: Option<String>,
49+
}
50+
4151
#[derive(Debug, Clone, Deserialize)]
4252
pub struct BuildConfig {
4353
#[serde(default)]
@@ -56,5 +66,6 @@ pub struct Crate {
5666
pub path: PathBuf,
5767
pub dependencies: Vec<CrateId>,
5868
pub configs: Vec<BuildConfig>,
69+
pub docs: MetadataEmbassyDocs,
5970
pub publish: bool,
6071
}

0 commit comments

Comments
 (0)