From e63df62d60c7dd9c5350b0d233790a4096ed8fd0 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Tue, 9 Apr 2024 05:43:16 +0000 Subject: [PATCH 1/2] feat: allow overriding the default FLUENTCI_ENGINE_VERSION to use --- README.md | 2 +- install.sh | 12 +++++------- src/consts.ts | 2 +- src/utils.ts | 35 ++++++++++++++++++++++++++++++++--- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e29533c..f62c8be 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ fluentci # Run the pipeline fluentci --help Usage: fluentci [pipeline] [jobs...] -Version: 0.12.0 +Version: 0.12.1 Description: diff --git a/install.sh b/install.sh index acb631f..dc7a88f 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e -o pipefail + readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')" readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')" readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')" @@ -98,13 +100,9 @@ tar -xzf /tmp/$ASSET_NAME -C /tmp chmod +x /tmp/fluentci # Move the extracted binary to the installation directory -# use sudo if OS is Linux -if [ "$OS" = "Linux" ]; then - if command -v sudo >/dev/null 2>&1; then - sudo mv /tmp/fluentci $INSTALL_DIR - else - mv /tmp/fluentci $INSTALL_DIR - fi +# use sudo if available +if command -v sudo >/dev/null 2>&1; then + sudo mv /tmp/fluentci $INSTALL_DIR else mv /tmp/fluentci $INSTALL_DIR fi diff --git a/src/consts.ts b/src/consts.ts index 751a58b..96e0c38 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -1,6 +1,6 @@ import { dir } from "../deps.ts"; -export const VERSION = "0.12.0"; +export const VERSION = "0.12.1"; export const BASE_URL = "https://api.fluentci.io/v1"; diff --git a/src/utils.ts b/src/utils.ts index 3f68bae..1869268 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -170,6 +170,26 @@ async function installDagger() { console.log("Dagger installed successfully"); } +export async function setupPkgx() { + Deno.env.set( + "PATH", + `${Deno.env.get("HOME")}/.local/bin:${Deno.env.get("PATH")}` + ); + const command = new Deno.Command("bash", { + args: ["-c", `type pkgx >/dev/null 2>&1 || curl -Ssf https://pkgx.sh | sh`], + stdout: "inherit", + stderr: "inherit", + }); + + const process = await command.spawn(); + const { code } = await process.status; + + if (code !== 0) { + console.log("Failed to install pkgx."); + Deno.exit(1); + } +} + export async function setupRust() { Deno.env.set( "PATH", @@ -194,6 +214,14 @@ export async function setupRust() { } export async function setupFluentCIengine() { + await setupPkgx(); + let FLUENTCI_ENGINE_VERSION = + Deno.env.get("FLUENTCI_ENGINE_VERSION") || "v0.2.5"; + + if (!FLUENTCI_ENGINE_VERSION.startsWith("v")) { + FLUENTCI_ENGINE_VERSION = `v${FLUENTCI_ENGINE_VERSION}`; + } + Deno.env.set( "PATH", `${Deno.env.get("HOME")}/.local/bin:${Deno.env.get("PATH")}` @@ -203,9 +231,10 @@ export async function setupFluentCIengine() { args: [ "-c", `\ - type fluentci-engine >/dev/null 2>&1 || wget https://github.com/fluentci-io/fluentci-engine/releases/download/v0.2.5/fluentci-engine_v0.2.5_${target}.tar.gz; - type fluentci-engine >/dev/null 2>&1 || tar xvf fluentci-engine_v0.2.5_${target}.tar.gz; - type fluentci-engine >/dev/null 2>&1 || rm fluentci-engine_v0.2.5_${target}.tar.gz; + [ -n "$FLUENTCI_ENGINE_VERSION" ] && type fluentci-engine >/dev/null 2>&1 && rm \`which fluentci-engine\`; + type fluentci-engine >/dev/null 2>&1 || pkgx wget https://github.com/fluentci-io/fluentci-engine/releases/download/${FLUENTCI_ENGINE_VERSION}/fluentci-engine_${FLUENTCI_ENGINE_VERSION}_${target}.tar.gz; + type fluentci-engine >/dev/null 2>&1 || pkgx tar xvf fluentci-engine_${FLUENTCI_ENGINE_VERSION}_${target}.tar.gz; + type fluentci-engine >/dev/null 2>&1 || rm fluentci-engine_${FLUENTCI_ENGINE_VERSION}_${target}.tar.gz; mkdir -p $HOME/.local/bin; type fluentci-engine >/dev/null 2>&1 || mv fluentci-engine $HOME/.local/bin;`, ], From 037780b24a88eedd016c9e63410d7e6ab440e4f6 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Tue, 9 Apr 2024 05:43:45 +0000 Subject: [PATCH 2/2] update flake.nix --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4863319..3431629 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,7 @@ packages.default = pkgs.deno2nix.mkExecutable { pname = "fluentci"; - version = "0.12.0"; + version = "0.12.1"; src = ./.; lockfile = "./deno.lock";