From 3532126d10201bbef2297b874e13ae3f88e21349 Mon Sep 17 00:00:00 2001 From: Markus Rudy Date: Wed, 6 Mar 2024 14:46:23 +0100 Subject: [PATCH] just: use released artifacts for demodir When demoing Contrast, we usually want a stable software version with a minimum amount of surprises, so we would like to use the released binary and coordinator YAML for that. This commit adds a script that downloads the artifacts, which is a bit complicated because of visibility restrictions, and modifies the just target to use this script. Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- justfile | 8 +++++--- packages/scripts.nix | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index 28b343896..22c2174ba 100644 --- a/justfile +++ b/justfile @@ -187,16 +187,18 @@ fmt: lint: nix run .#scripts.golangci-lint -- run -demodir cli=default_cli: undeploy coordinator initializer +demodir namespace="default": coordinator initializer #!/usr/bin/env bash d=$(mktemp -d) echo "Creating demo directory at ${d}" - nix build .#{{ cli }} - cp ./result-cli/bin/contrast "${d}/contrast" cp -R ./deployments/emojivoto "${d}/deployment" + rm -f "${d}/deployment/coordinator.yml" nix run .#scripts.patch-contrast-image-hashes -- "${d}/deployment" nix run .#kypatch images -- "${d}/deployment" \ --replace ghcr.io/edgelesssys ${container_registry} + nix run .#kypatch namespace -- "${d}/deployment" \ + --replace edg-default {{ namespace }} + nix run .#scripts.fetch-latest-contrast -- {{ namespace }} "${d}" echo "Demo directory ready at ${d}" # Cleanup auxiliary files, caches etc. diff --git a/packages/scripts.nix b/packages/scripts.nix index 799e31880..7c1377fec 100644 --- a/packages/scripts.nix +++ b/packages/scripts.nix @@ -168,4 +168,24 @@ with pkgs; popd >/dev/null ''; }; + + fetch-latest-contrast = writeShellApplication { + name = "fetch-latest-contrast"; + runtimeInputs = [ + jq + github-cli + ]; + text = '' + namespace=$1 + targetDir=$2 + release=$(gh release list --json name,isLatest | jq -r '.[] | select(.isLatest) | .name') + gh release download "$release" \ + --repo edgelesssys/contrast \ + -D "$targetDir" \ + --skip-existing + chmod a+x "$targetDir/contrast" + + yq -i ".metadata.namespace = \"$namespace\"" "$targetDir/coordinator.yaml" + ''; + }; }