fix caching by ignoring semver build metadata

This commit is contained in:
Mark Delk 2023-11-23 22:00:00 -06:00
parent c7b6cdd3ad
commit 9f5e80ae9e
3 changed files with 17455 additions and 970 deletions

18397
dist/index.js vendored

File diff suppressed because one or more lines are too long

14
test.js
View File

@ -1,4 +1,5 @@
const assert = require('assert').strict
const semver = require('semver')
const {
resolveCommit,
resolveVersion
@ -7,13 +8,18 @@ const {
async function test () {
assert.deepEqual(resolveCommit('linux', '0.6.0+4b48fccad'), {
downloadUrl: 'https://ziglang.org/builds/zig-linux-x86_64-0.6.0+4b48fccad.tar.xz',
variantName: 'zig-linux-x86_64-0.6.0+4b48fccad',
version: '0.6.0+4b48fccad'
variantName: 'zig-linux-x86_64-0.6.0',
version: '0.6.0'
})
assert.deepEqual(resolveCommit('win32', '0.6.0+4b48fccad'), {
downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.6.0+4b48fccad.zip',
variantName: 'zig-windows-x86_64-0.6.0+4b48fccad',
version: '0.6.0+4b48fccad'
variantName: 'zig-windows-x86_64-0.6.0',
version: '0.6.0'
})
assert.deepEqual(resolveCommit('win32', '0.12.0-dev.1092+68ed78775'), {
downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.12.0-dev.1092+68ed78775.zip',
variantName: 'zig-windows-x86_64-0.12.0-dev.1092',
version: '0.12.0-dev.1092'
})
assert.deepEqual(await resolveVersion('linux', '0.7.0'), {

View File

@ -19,9 +19,11 @@ function resolveCommit (platform, version) {
}[platform]
const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}`
const variantName = `zig-${addrhost}-${version}`
return { downloadUrl, variantName, version }
const versionWithoutBuildHash = semver.clean(version)
const variantName = `zig-${addrhost}-${versionWithoutBuildHash}`
return { downloadUrl, variantName, version: versionWithoutBuildHash }
}
function getJSON (opts) {