diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f6419deccb52bd46de702b57f48b4abadf7c427..331fbe4cfcd6209063c4faf9b766191e40aaa6a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -358,7 +358,7 @@ create_network_release: - <<: *is_network_branch image: rust:1-bullseye variables: - # Used by `release-runtime` command + # Used by `release-network` command SRTOOL_OUTPUT: $CI_PROJECT_DIR/release/srtool_output.json script: - *define_network_branch_vars @@ -384,9 +384,12 @@ create_client_release: rules: - <<: *is_network_branch image: rust:1-bullseye + variables: + # Used by `release-runtime` command + SRTOOL_OUTPUT: $CI_PROJECT_DIR/release/srtool_output.json script: - *define_network_branch_vars - - cargo xtask release-runtime $RUNTIME_MILESTONE $CI_COMMIT_BRANCH + - cargo xtask release-runtime $NETWORK_RELEASE $CI_COMMIT_BRANCH $RUNTIME_MILESTONE - cargo xtask create-asset-link $RUNTIME_MILESTONE ${RUNTIME}_runtime.compact.compressed.wasm https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_WASM - cargo xtask create-asset-link $RUNTIME_MILESTONE ${RUNTIME}_client-specs.yaml https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_CLIENT_SPEC - cargo xtask create-asset-link $RUNTIME_MILESTONE ${RUNTIME}-raw.json https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_RAW_SPEC diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 7e4c823825d62cec505ca753f4a7b66e99472e5a..f84b3420bea65147a57282d7d7d7db286f5e56a6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -54,7 +54,11 @@ enum DuniterXTaskCommand { /// Release a new network ReleaseNetwork { network: String, branch: String }, /// Release a new runtime - ReleaseRuntime { milestone: String, branch: String }, + ReleaseRuntime { + network: String, + branch: String, + milestone: String, + }, /// Print the chainSpec published on given Network Release PrintSpec { network: String }, /// Create asset in a release @@ -99,9 +103,11 @@ async fn main() -> Result<()> { DuniterXTaskCommand::ReleaseNetwork { network, branch } => { release_runtime::release_network(network, branch).await } - DuniterXTaskCommand::ReleaseRuntime { milestone, branch } => { - release_runtime::release_runtime(milestone, branch).await - } + DuniterXTaskCommand::ReleaseRuntime { + network, + branch, + milestone, + } => release_runtime::release_runtime(network, branch, milestone).await, DuniterXTaskCommand::PrintSpec { network } => release_runtime::print_spec(network).await, DuniterXTaskCommand::CreateAssetLink { tag, diff --git a/xtask/src/release_runtime.rs b/xtask/src/release_runtime.rs index c39f4a44104a08eee4edc00ee81e16affe4f1b73..574867ea6fb1de543684700bccb461442eea042a 100644 --- a/xtask/src/release_runtime.rs +++ b/xtask/src/release_runtime.rs @@ -69,28 +69,7 @@ pub(super) async fn release_network(network: String, branch: String) -> Result<( ", ); - - // Generate release notes - let currency = network.clone(); - let env_var = "SRTOOL_OUTPUT".to_string(); - - if let Ok(sr_tool_output_file) = std::env::var(env_var) { - let read = fs::read_to_string(sr_tool_output_file); - match read { - Ok(sr_tool_output) => { - release_notes.push_str( - gen_release_notes(currency.to_string(), sr_tool_output) - .with_context(|| { - format!("Fail to generate release notes for {}", currency) - })? - .as_str(), - ); - } - Err(e) => { - eprintln!("srtool JSON output could not be read ({}). Skipped.", e) - } - } - } + add_srtool_notes(network.clone(), &mut release_notes)?; println!("{}", release_notes); let gitlab_token = @@ -106,42 +85,19 @@ pub(super) async fn release_network(network: String, branch: String) -> Result<( Ok(()) } -pub(super) async fn release_runtime(milestone: String, branch: String) -> Result<()> { - // TODO:Â check spec_version in the code and bump if necessary (with a commit) - // TODO: create and push a git tag runtime-{spec_version} - +pub(super) async fn release_runtime( + network: String, + branch: String, + milestone: String, +) -> Result<()> { let mut release_notes = String::from( " -# Runtimes +# Runtime ", ); - // Generate release notes - let runtimes = vec![ - ("ÄžDev", "SRTOOL_OUTPUT_GDEV"), - ("ÄžTest", "SRTOOL_OUTPUT_GTEST"), - ("Äž1", "SRTOOL_OUTPUT_G1"), - ]; - for (currency, env_var) in runtimes { - if let Ok(sr_tool_output_file) = std::env::var(env_var) { - let read = fs::read_to_string(sr_tool_output_file); - match read { - Ok(sr_tool_output) => { - release_notes.push_str( - gen_release_notes(currency.to_string(), sr_tool_output) - .with_context(|| { - format!("Fail to generate release notes for {}", currency) - })? - .as_str(), - ); - } - Err(e) => { - eprintln!("srtool JSON output could not be read ({}). Skipped.", e) - } - } - } - } + add_srtool_notes(network, &mut release_notes)?; // Get changes (list of MRs) from gitlab API let changes = get_changes::get_changes(milestone.clone()).await?; @@ -179,6 +135,31 @@ pub(super) async fn release_runtime(milestone: String, branch: String) -> Result Ok(()) } +fn add_srtool_notes(network: String, release_notes: &mut String) -> Result<()> { + // Generate release notes + let currency = network.clone(); + let env_var = "SRTOOL_OUTPUT".to_string(); + + if let Ok(sr_tool_output_file) = std::env::var(env_var) { + let read = fs::read_to_string(sr_tool_output_file); + match read { + Ok(sr_tool_output) => { + release_notes.push_str( + gen_release_notes(currency.to_string(), sr_tool_output) + .with_context(|| { + format!("Fail to generate release notes for {}", currency) + })? + .as_str(), + ); + } + Err(e) => { + eprintln!("srtool JSON output could not be read ({}). Skipped.", e) + } + } + } + Ok(()) +} + pub(super) async fn print_spec(network: String) -> Result<()> { let spec_file = match network.clone() { network if network.starts_with("g1") => "g1.json",