Skip to content
This repository was archived by the owner on Oct 5, 2024. It is now read-only.

Commit 81446a4

Browse files
authored
feat: cache master version in real version spec (#62)
* feat: cache master version in real version spec Signed-off-by: tison <wander4096@gmail.com> * gen Signed-off-by: tison <wander4096@gmail.com> --------- Signed-off-by: tison <wander4096@gmail.com>
1 parent 38ed7ba commit 81446a4

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

dist/index.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,19 @@ async function main(): Promise<void> {
9292
if (!availableVersions.includes(zigVersion)) {
9393
throw new Error(`Unsupported version: ${zigVersion}`)
9494
}
95-
core.info(`Using version ${zigVersion}...`)
9695

9796
const zigVersionedDistro = (zigDistros as Record<string, any>)[zigVersion]
97+
const versionSpec = zigVersion !== 'master' ? zigVersion : zigVersionedDistro['version']
98+
core.info(`Using version ${versionSpec}...`)
99+
98100
const targetPlatform: string = await resolveTargetPlatform()
99101
const availablePlatform = Object.keys(zigVersionedDistro)
100102
if (!availablePlatform.includes(targetPlatform)) {
101103
throw new Error(`Unsupported platform: ${targetPlatform}`)
102104
}
103105
core.info(`Targeting to platform ${targetPlatform}...`)
104106

105-
const toolPath = cache.find('zig', zigVersion, targetPlatform)
107+
const toolPath = cache.find('zig', versionSpec, targetPlatform)
106108
if (toolPath) {
107109
core.info(`Cache hit ${toolPath}`)
108110
core.addPath(toolPath)
@@ -125,7 +127,7 @@ async function main(): Promise<void> {
125127
} else {
126128
throw new Error(`Unsupported compression: ${tarballLink}`)
127129
}
128-
const cachedToolPath = await cache.cacheDir(extractedPath, 'zig', zigVersion, targetPlatform)
130+
const cachedToolPath = await cache.cacheDir(extractedPath, 'zig', versionSpec, targetPlatform)
129131
core.info(`Cache new ${cachedToolPath}`)
130132
core.addPath(cachedToolPath)
131133
}

0 commit comments

Comments
 (0)