diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fdbebf62cb413b8ba5eda4759c234a2094a3e29..9c17d9582c295fd25593744f0290ec2bd3c9f55d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -188,8 +188,8 @@ tests: - echo $CLIENT_VERSION - export RUNTIME_VERSION=$(cat runtime/gdev/src/lib.rs | grep "spec_version:" | sed "s/ *spec_version. //g" | sed "s/,//g") - echo $RUNTIME_VERSION - - export RUNTIME_MILESTONE="runtime-$RUNTIME_VERSION" - - echo $RUNTIME_MILESTONE + - export CLIENT_MILESTONE="client-$CLIENT_VERSION" + - echo $CLIENT_MILESTONE - export NETWORK_RELEASE="$NETWORK" - echo $NETWORK_RELEASE - export DOCKER_TAG="$RUNTIME_VERSION-$CLIENT_VERSION" @@ -260,11 +260,10 @@ docker_deploy: ############## SRTOOL ############## -# We always build the runtime on a network/ branch, either it is for: -# - creating a network release (i.e.: genesis) -# - creating a client release (i.e.: which also includes the runtime) -build_runtime: +# The Network Runtime is only built when creating a network release (i.e.: genesis) +build_network_runtime: stage: build + needs: ["trigger_network_release"] rules: - <<: *is_network_branch image: paritytech/srtool:1.77.0-0.15.0 @@ -340,7 +339,7 @@ g1_data: build_specs: stage: build - needs: ["build_runtime", "g1_data"] + needs: ["build_network_runtime", "g1_data"] rules: - <<: *is_network_branch extends: .env @@ -425,17 +424,15 @@ create_network_release: create_client_release: stage: release - needs: ["build_runtime", "build_raw_specs"] + needs: ["build_raw_specs"] 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 $CLIENT_RELEASE_NAME $NETWORK_RELEASE $CI_COMMIT_BRANCH $RUNTIME_MILESTONE - - cargo xtask create-asset-link $CLIENT_RELEASE_NAME ${RUNTIME}_runtime.compact.compressed.wasm https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_WASM + # Create the GitLab release page + tag and associate the milestone + - cargo xtask release-client $CLIENT_RELEASE_NAME $CI_COMMIT_BRANCH $CLIENT_MILESTONE + # Add the client assets - cargo xtask create-asset-link $CLIENT_RELEASE_NAME ${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 $CLIENT_RELEASE_NAME ${RUNTIME}-raw.json https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_RAW_SPEC artifacts: diff --git a/xtask/src/gitlab.rs b/xtask/src/gitlab.rs index 9f9d61548e0e51f47c14ca5b76519a2a2b133940..e4fb1b26cb6e5280c928baa674ca3b98e528de58 100644 --- a/xtask/src/gitlab.rs +++ b/xtask/src/gitlab.rs @@ -91,14 +91,37 @@ pub(super) async fn release_runtime( branch: String, milestone: String, ) -> Result<()> { - let mut release_notes = String::from( + release( + "Runtime".to_string(), + name, + Some(network), + branch, + milestone, + ) + .await +} + +pub(super) async fn release_client(name: String, branch: String, milestone: String) -> Result<()> { + release("Client".to_string(), name, None, branch, milestone).await +} + +async fn release( + title: String, + name: String, + network: Option<String>, + branch: String, + milestone: String, +) -> Result<()> { + let mut release_notes = String::from(format!( " -# Runtime +# {title} -", - ); +" + )); - add_srtool_notes(network, &mut release_notes)?; + if let Some(network) = network { + add_srtool_notes(network.clone(), &mut release_notes)?; + } // Get changes (list of MRs) from gitlab API let changes = get_changes::get_changes(milestone.clone()).await?; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index df700dff40532189bda0150b98485a7074321376..fd574f057c783af78dad2517d42b292c1ac491f3 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -57,9 +57,22 @@ enum DuniterXTaskCommand { ReleaseNetwork { network: String, branch: String }, /// Release a new runtime ReleaseRuntime { + /// Name of the release + tag to be applied name: String, + /// Name of the network to be put in the release notes title of the srtool part network: String, + /// Branch on which the tag `name` will be created during the release branch: String, + /// Name of the milestone to add this release to + milestone: String, + }, + /// Release a new client for a network + ReleaseClient { + /// Name of the release + tag to be applied + name: String, + /// Branch on which the tag `name` will be created during the release + branch: String, + /// Name of the milestone to add this release to milestone: String, }, /// Print the chainSpec published on given Network Release @@ -112,6 +125,11 @@ async fn main() -> Result<()> { branch, milestone, } => gitlab::release_runtime(name, network, branch, milestone).await, + DuniterXTaskCommand::ReleaseClient { + name, + branch, + milestone, + } => gitlab::release_client(name, branch, milestone).await, DuniterXTaskCommand::PrintSpec { network } => gitlab::print_spec(network).await, DuniterXTaskCommand::CreateAssetLink { tag,