From 0c54d93a31b6fafeed63783357eb51d8c0e18d46 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Wed, 13 Dec 2023 18:41:55 +0200 Subject: [PATCH] ci: fix covector latest version check --- .scripts/package-latest-version.js | 62 +++++++++++++++++------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/.scripts/package-latest-version.js b/.scripts/package-latest-version.js index addc13f..1cfbfe0 100644 --- a/.scripts/package-latest-version.js +++ b/.scripts/package-latest-version.js @@ -8,32 +8,42 @@ This script is solely intended to be run as part of the `covector publish` step check the latest version of a crate, considering the current minor version. */ -const https = require('https') - -const packageName = process.argv[2] -const packageVersion = process.argv[3] -const target = packageVersion.substring(0, packageVersion.lastIndexOf('.')) +const https = require("https"); +const packageName = process.argv[2]; +const packageVersion = process.argv[3]; +const target = packageVersion.substring(0, packageVersion.lastIndexOf(".")); const options = { - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - "Authorization": process.env["GITHUB_TOKEN"] ? `Bearer <${process.env["GITHUB_TOKEN"]}>` : null, - 'User-Agent': 'tauri (https://github.com/tauri-apps/nsis-tauri-utils)' - } -} - -https.get("https://api.github.com/repos/tauri-apps/nsis-tauri-utils/releases", options, (response) => { - let chunks = [] - response.on('data', function (chunk) { - chunks.push(chunk) - }) - - response.on('end', function () { - const data = JSON.parse(chunks.join('')) - const versions = data.filter(t => t.tag_name.startsWith(`${packageName}-v${target}`)) - console.log(versions.length ? versions[0].tag_name : '0.0.0') - - }) -}) + headers: { + "Content-Type": "application/json", + Accept: "application/json", + Authorization: process.env["GITHUB_TOKEN"] + ? `Bearer <${process.env["GITHUB_TOKEN"]}>` + : null, + "User-Agent": "tauri (https://github.com/tauri-apps/nsis-tauri-utils)", + }, +}; + +https.get( + "https://api.github.com/repos/tauri-apps/nsis-tauri-utils/releases", + options, + (response) => { + let chunks = []; + response.on("data", function (chunk) { + chunks.push(chunk); + }); + + response.on("end", function () { + const data = JSON.parse(chunks.join("")); + const versions = data.filter((t) => + t.tag_name.startsWith(`${packageName}-v${target}`) + ); + console.log( + versions.length + ? versions[0].tag_name.replace(`${packageName}-v`, "") + : "0.0.0" + ); + }); + } +);