Skip to content

Commit

Permalink
feat(ci): Make github releases on git tag push (#53)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sasa-tomic committed Jan 11, 2024
1 parent 8afd9c7 commit 378dcf3
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 18 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/bazel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <id> replace -o1
dre --dev subnet --id <id> replace -o1
```
Original file line number Diff line number Diff line change
Expand Up @@ -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"} <b>{deadNodes.length}</b> dead node{deadNodes.length > 1 && "s"} that need{deadNodes.length === 1 && "s"} to be replaced.</>,
})
}
Expand All @@ -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"} <b>{degraded.length}</b> degraded node{degraded.length > 1 && "s"} that might need to be replaced.</>,
})
}
Expand Down
4 changes: 2 additions & 2 deletions rs/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DEPS = [
]

rust_binary(
name = "release_cli",
name = "dre",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(),
proc_macro_deps = all_crate_deps(
Expand All @@ -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,
),
Expand Down
4 changes: 2 additions & 2 deletions rs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +40,7 @@ will not carry it). See below under *Troubleshooting* to get that going.
## Usage

```shell
release_cli --help
dre --help
```

## Troubleshooting
Expand Down
4 changes: 2 additions & 2 deletions rs/cli/src/ic_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions rs/ic-management-backend/src/endpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::sync::mpsc::Sender<actix_web::dev::ServerHandle>>,
) -> 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(&registry_state).await;
} else {
if std::env::var(GITLAB_TOKEN_RELEASE_ENV).is_err() {
Expand All @@ -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()
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 378dcf3

Please sign in to comment.