From 378dcf3ba72d35ff0d9b44e610ee8df0815bfb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Thu, 11 Jan 2024 17:39:21 +0100 Subject: [PATCH] feat(ci): Make github releases on git tag push (#53) * feat(ci): Make github releases on git tag push * fix syntax * Revert testing changes * Adjust the GH action to make a draft release only * Replace more mentions of "release_cli" * Update comment * Do not tolerate bash errors --- .github/workflows/bazel.yaml | 25 ++++++++++++++++++- CHANGELOG.md | 4 +++ README.md | 4 +-- .../src/components/subnets/SubnetsBoard.tsx | 4 +-- rs/cli/BUILD.bazel | 4 +-- rs/cli/README.md | 4 +-- rs/cli/src/ic_admin.rs | 4 +-- rs/ic-management-backend/src/endpoints/mod.rs | 14 +++++------ 8 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/bazel.yaml b/.github/workflows/bazel.yaml index 262f1fbb1..968603146 100644 --- a/.github/workflows/bazel.yaml +++ b/.github/workflows/bazel.yaml @@ -32,4 +32,27 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - run: bazel query --noshow_progress 'kind("oci_push", ...)' | xargs -I_target bazel run _target -- --tag ${GITHUB_SHA} + - name: Get bazel binaries, so they can be pushed as GitHub artifacts in the next step + if: startsWith(github.ref, 'refs/tags/v') + run: | + set -eExuo pipefail + # query the location of the bazel "dre" binary and copy it to the "release" directory + mkdir -p release + cp --dereference bazel-out/k8-opt/bin/rs/cli/dre release/dre + chmod +x release/dre + - name: Create a new GitHub Release + if: startsWith(github.ref, 'refs/tags/v') + # v0.1.15 + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body_path: CHANGELOG.md + generate_release_notes: true + draft: true + prerelease: true + files: | + release/* + - name: Push images to GitHub Container Registry + if: startsWith(github.ref, 'refs/tags/v') + run: + bazel query --noshow_progress 'kind("oci_push", ...)' | xargs -I_target bazel run _target -- --tag ${GITHUB_SHA} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..024ef55e3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +## 0.1.0 + +- Initial public release +- The tooling from this repo can help for Internet Computer operations: querying current state, submitting NNS proposals, etc. diff --git a/README.md b/README.md index 32ce632e5..e773ea0e9 100644 --- a/README.md +++ b/README.md @@ -206,10 +206,10 @@ To start the release dashboard locally, run the following from dashboard folder yarn dev ``` -To use `release_cli` with the local dashboard instance run it with `--dev` flag. +To use the `dre` CLI tool with the local dashboard instance run it with `--dev` flag. E.g. ```sh -release_cli --dev subnet --id replace -o1 +dre --dev subnet --id replace -o1 ``` diff --git a/dashboard/packages/app/src/components/subnets/SubnetsBoard.tsx b/dashboard/packages/app/src/components/subnets/SubnetsBoard.tsx index 3d46643e8..e9b8578d5 100644 --- a/dashboard/packages/app/src/components/subnets/SubnetsBoard.tsx +++ b/dashboard/packages/app/src/components/subnets/SubnetsBoard.tsx @@ -150,7 +150,7 @@ function generateSubnetActions(subnet: Subnet, healths: { [principal: string]: N actions.push({ type: "heal", urgency: deadNodes.length / subnet.nodes.length > 0.1 ? "critical" : "warning", - description: `release_cli subnet --id ${subnet.principal} replace # dead nodes: ${deadNodes.map(dn => dn.principal.split('-')[0]+"/"+dn.hostname)}`, + description: `dre subnet --id ${subnet.principal} replace # dead nodes: ${deadNodes.map(dn => dn.principal.split('-')[0] + "/" + dn.hostname)}`, message: <>There {deadNodes.length === 1 ? "is" : "are"} {deadNodes.length} dead node{deadNodes.length > 1 && "s"} that need{deadNodes.length === 1 && "s"} to be replaced., }) } @@ -159,7 +159,7 @@ function generateSubnetActions(subnet: Subnet, healths: { [principal: string]: N actions.push({ type: "heal", urgency: degraded.length / subnet.nodes.length > 0.2 ? "critical" : "warning", - description: `release_cli subnet --id ${subnet.principal} replace # degraded nodes: ${degraded.map(dn => dn.principal.split('-')[0]+"/"+dn.hostname)}`, + description: `dre subnet --id ${subnet.principal} replace # degraded nodes: ${degraded.map(dn => dn.principal.split('-')[0] + "/" + dn.hostname)}`, message: <>There {degraded.length === 1 ? "is" : "are"} {degraded.length} degraded node{degraded.length > 1 && "s"} that might need to be replaced., }) } diff --git a/rs/cli/BUILD.bazel b/rs/cli/BUILD.bazel index e6e81ea03..8b88c3ead 100644 --- a/rs/cli/BUILD.bazel +++ b/rs/cli/BUILD.bazel @@ -11,7 +11,7 @@ DEPS = [ ] rust_binary( - name = "release_cli", + name = "dre", srcs = glob(["src/**/*.rs"]), aliases = aliases(), proc_macro_deps = all_crate_deps( @@ -29,7 +29,7 @@ rust_test( normal_dev = True, proc_macro_dev = True, ), - crate = ":release_cli", + crate = ":dre", proc_macro_deps = all_crate_deps( proc_macro_dev = True, ), diff --git a/rs/cli/README.md b/rs/cli/README.md index 53ce551a6..1c44ee7a6 100644 --- a/rs/cli/README.md +++ b/rs/cli/README.md @@ -31,7 +31,7 @@ sudo ln -s /usr/local/homebrew/Cellar/openssl@3/3.0.8 /usr/local/opt/openssl@3 ## Install ```shell -cargo install --git ssh://git@gitlab.com/dfinity-lab/core/release release_cli +cargo install --git https://github.com/dfinity/dre.git dre ``` Make sure you have `libssl.so.1.1` on your system (Ubuntu 22.04 and later @@ -40,7 +40,7 @@ will not carry it). See below under *Troubleshooting* to get that going. ## Usage ```shell -release_cli --help +dre --help ``` ## Troubleshooting diff --git a/rs/cli/src/ic_admin.rs b/rs/cli/src/ic_admin.rs index 2ecbdc1e3..cb1d8268f 100644 --- a/rs/cli/src/ic_admin.rs +++ b/rs/cli/src/ic_admin.rs @@ -233,13 +233,13 @@ impl IcAdminWrapper { let args = if args[0].starts_with("get-") { // The user did provide the "get-" prefix, so let's just keep it and use it. // This provides a convenient backward compatibility with ic-admin commands - // i.e., `release_cli get get-subnet 0` still works, although `release_cli get + // i.e., `dre get get-subnet 0` still works, although `dre get // subnet 0` is preferred args.to_vec() } else { // But since ic-admin expects these commands to include the "get-" prefix, we // need to add it back Example: - // `release_cli get subnet 0` becomes + // `dre get subnet 0` becomes // `ic-admin --nns-url "http://[2600:3000:6100:200:5000:b0ff:fe8e:6b7b]:8080" get-subnet 0` let mut args_with_get_prefix = vec![String::from("get-") + args[0].as_str()]; args_with_get_prefix.extend_from_slice(args.split_at(1).1); diff --git a/rs/ic-management-backend/src/endpoints/mod.rs b/rs/ic-management-backend/src/endpoints/mod.rs index dc64c4490..4051458f4 100644 --- a/rs/ic-management-backend/src/endpoints/mod.rs +++ b/rs/ic-management-backend/src/endpoints/mod.rs @@ -32,15 +32,15 @@ pub async fn run_backend( target_network: Network, listen_ip: &str, listen_port: u16, - run_from_release_cli: bool, + run_from_cli: bool, mpsc_tx: Option>, ) -> std::io::Result<()> { debug!("Starting backend"); let registry_state = Arc::new(RwLock::new( - registry::RegistryState::new(target_network.clone(), run_from_release_cli).await, + registry::RegistryState::new(target_network.clone(), run_from_cli).await, )); - if run_from_release_cli { + if run_from_cli { registry::update_node_details(®istry_state).await; } else { if std::env::var(GITLAB_TOKEN_RELEASE_ENV).is_err() { @@ -62,11 +62,11 @@ pub async fn run_backend( }); } - let num_workers = if run_from_release_cli { 1 } else { 8 }; + let num_workers = if run_from_cli { 1 } else { 8 }; let mut srv = HttpServer::new(move || { let network = target_network.clone(); - // For release_cli invocations we don't need more than one worker + // For `dre` cli invocations we don't need more than one worker let middleware_registry_state = registry_state.clone(); App::new() @@ -83,7 +83,7 @@ pub async fn run_backend( if registry_canister .get_latest_version() .await - .map_or(true, |v| v != registry_version && !run_from_release_cli) + .map_or(true, |v| v != registry_version && !run_from_cli) { Err(actix_web::error::ErrorServiceUnavailable("version updating")) } else { @@ -123,7 +123,7 @@ pub async fn run_backend( .bind((listen_ip, listen_port)) .unwrap(); - if run_from_release_cli { + if run_from_cli { // params reference: https://github.com/actix/actix-web/blob/master/actix-web/tests/test_httpserver.rs srv = srv .backlog(1)