From fa3b4549621368eafbc2175dafe72c9a6b5d64a6 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Fri, 3 May 2024 05:00:29 +0000 Subject: [PATCH] install the latest version of fluentci-engine if FLUENTCI_ENGINE_VERSION is not set --- README.md | 2 +- src/consts.ts | 2 +- src/utils.ts | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d3bdc50..a4e7a8c 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ fluentci # Run the pipeline fluentci --help Usage: fluentci [pipeline] [jobs...] -Version: 0.13.0 +Version: 0.13.1 Description: diff --git a/src/consts.ts b/src/consts.ts index 5dc8277..fe13128 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -1,6 +1,6 @@ import { dir } from "../deps.ts"; -export const VERSION = "0.13.0"; +export const VERSION = "0.13.1"; export const BASE_URL = "https://api.fluentci.io/v1"; diff --git a/src/utils.ts b/src/utils.ts index 90c4505..850348e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -225,8 +225,24 @@ export async function setupRust() { export async function setupFluentCIengine() { await setupPkgx(); - let FLUENTCI_ENGINE_VERSION = - Deno.env.get("FLUENTCI_ENGINE_VERSION") || "v0.2.5"; + let FLUENTCI_ENGINE_VERSION = Deno.env.get("FLUENTCI_ENGINE_VERSION"); + + if (!FLUENTCI_ENGINE_VERSION) { + FLUENTCI_ENGINE_VERSION = await fetch( + "https://api.github.com/repos/fluentci-io/fluentci-engine/releases/latest" + ) + .then((res) => res.json()) + .then((data) => data.tag_name) + .catch(() => { + console.error("Failed to fetch latest release."); + Deno.exit(1); + }); + } + + if (!FLUENTCI_ENGINE_VERSION) { + console.error("Failed to fetch latest release."); + Deno.exit(1); + } if (!FLUENTCI_ENGINE_VERSION.startsWith("v")) { FLUENTCI_ENGINE_VERSION = `v${FLUENTCI_ENGINE_VERSION}`; @@ -241,7 +257,7 @@ export async function setupFluentCIengine() { args: [ "-c", `\ - [ -n "$FLUENTCI_ENGINE_VERSION" ] && type fluentci-engine >/dev/null 2>&1 && rm \`which fluentci-engine\`; + [ -n "$FORCE_FLUENTCI_ENGINE_INSTALL" ] && 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;