Skip to content

Commit

Permalink
ci: fix covector latest version check
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Dec 13, 2023
1 parent b73e15a commit 0c54d93
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions .scripts/package-latest-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
});
}
);

0 comments on commit 0c54d93

Please sign in to comment.