Skip to content

Commit

Permalink
feat: add package name to docker and npm wf
Browse files Browse the repository at this point in the history
  • Loading branch information
loispostula committed Jul 21, 2024
1 parent 8611ae8 commit 2ac26f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/commands/generate_workflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ pub async fn generate_workflow(
}
if member.publish_detail.docker.publish {
member_workflows.push(Box::new(PublishDockerWorkflow::new(
member_key.clone(),
member_key.clone(),
working_directory.clone(),
member.publish_detail.docker.context.clone(),
Expand All @@ -699,6 +700,7 @@ pub async fn generate_workflow(
}
if member.publish_detail.npm_napi.publish {
member_workflows.push(Box::new(PublishNpmNapiWorkflow::new(
member_key.clone(),
working_directory.clone(),
&dynamic_value_base,
)));
Expand Down
5 changes: 5 additions & 0 deletions src/commands/generate_workflow/workflows/publish_docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub struct PublishDockerWorkflowOutputs {

#[derive(Default, Clone)]
pub struct PublishDockerWorkflowInputs {
/// Package name
pub package: String,
/// Docker image
pub image: String,
/// Docker Context image
Expand All @@ -28,6 +30,7 @@ pub struct PublishDockerWorkflowInputs {
impl From<&PublishDockerWorkflowInputs> for IndexMap<String, Value> {
fn from(val: &PublishDockerWorkflowInputs) -> Self {
let mut map: IndexMap<String, Value> = IndexMap::new();
map.insert("package".to_string(), val.package.clone().into());
map.insert("image".to_string(), val.image.clone().into());
map.insert("toolchain".to_string(), val.toolchain.clone().into());
if let Some(context) = &val.context {
Expand All @@ -54,6 +57,7 @@ pub struct PublishDockerWorkflow {

impl PublishDockerWorkflow {
pub fn new(
package: String,
image: String,
working_directory: String,
context: Option<String>,
Expand All @@ -63,6 +67,7 @@ impl PublishDockerWorkflow {
) -> Self {
Self {
inputs: PublishDockerWorkflowInputs {
package,
image,
working_directory,
context,
Expand Down
10 changes: 8 additions & 2 deletions src/commands/generate_workflow/workflows/publish_npm_napi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ pub struct PublishNpmNapiWorkflowOutputs {

#[derive(Default, Clone)]
pub struct PublishNpmNapiWorkflowInputs {
/// Package name
pub package: String,
/// Working directory to run the cargo command
pub working_directory: String,
}

impl From<&PublishNpmNapiWorkflowInputs> for IndexMap<String, Value> {
fn from(val: &PublishNpmNapiWorkflowInputs) -> Self {
let mut map: IndexMap<String, Value> = IndexMap::new();
map.insert("package".to_string(), val.package.clone().into());
map.insert(
"working_directory".to_string(),
val.working_directory.clone().into(),
Expand All @@ -32,9 +35,12 @@ pub struct PublishNpmNapiWorkflow {
}

impl PublishNpmNapiWorkflow {
pub fn new(working_directory: String, _dynamic_value_base: &str) -> Self {
pub fn new(package: String, working_directory: String, _dynamic_value_base: &str) -> Self {
Self {
inputs: PublishNpmNapiWorkflowInputs { working_directory },
inputs: PublishNpmNapiWorkflowInputs {
package,
working_directory,
},
_outputs: None,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ impl PublishRustBinaryWorkflow {
Self {
inputs: PublishRustBinaryWorkflowInputs {
package,
version: format!("${{{{ {}.{}) }}}}", dynamic_value_base, "publish_detail.binary.rc_version"),
version: format!(
"${{{{ {}.{}) }}}}",
dynamic_value_base, "publish_detail.binary.rc_version"
),
toolchain: format!("${{{{ {}.{}) }}}}", dynamic_value_base, "toolchain"),
release_channel: format!(
"${{{{ {}.{}) }}}}",
Expand Down

0 comments on commit 2ac26f2

Please sign in to comment.