Skip to content

Commit

Permalink
chore: fix edge build release artifact filenames (#5449)
Browse files Browse the repository at this point in the history
#5440 accidentally changed the release asset filenames in our edge release: https://github.com/garden-io/garden/releases/tag/edge-bonsai

They used to look like this:
`garden-edge-bonsai-alpine-amd64.tar.gz` and now look like this: `garden-0.13.20-edge-bonsai-2779705b6-alpine-amd64.tar.gz`

This commit reverts to the old filenames so self-update downloads the correct artifacts.
  • Loading branch information
stefreak authored Nov 20, 2023
1 parent 84ece1d commit 8d00dc9
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions cli/src/build-pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,22 @@ async function zipAndHash({ targetDir, archiveName, cwd, prefix, fileNames }: Zi
async function buildBinaries(args: string[]) {
const argv = minimist(args)

let version: string
// The string that the `garden version` command outputs
let versionInBinary: string

if (argv.version === "edge" || argv.version.startsWith("edge-")) {
// The string in our release tarball/zip filenames
let versionInFilename: string

if (argv.version && (argv.version === "edge" || argv.version.startsWith("edge-"))) {
const gitHash = await exec("git", ["rev-parse", "--short", "HEAD"])
version = `${getPackageVersion()}-${argv.version}-${gitHash.stdout}`
versionInBinary = `${getPackageVersion()}-${argv.version}-${gitHash.stdout}`
versionInFilename = argv.version
} else if (argv.version) {
console.log(`Cannot set Garden to version ${argv.version}. Please update the package.json files instead.`)
process.exit(1)
} else {
version = getPackageVersion()
versionInBinary = getPackageVersion()
versionInFilename = versionInBinary
}

const selected = argv._.length > 0 ? pick(targets, argv._) : targets
Expand Down Expand Up @@ -283,10 +289,8 @@ async function buildBinaries(args: string[]) {
packageJson.dependencies[depName] = "file:" + relPath
}

if (version) {
packageJson.version = version
console.log(`Updated version to ${packageJson.version} in ${packageJsonPath}`)
}
packageJson.version = versionInBinary
console.log(`Updated version to ${packageJson.version} in ${packageJsonPath}`)

await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2))

Expand All @@ -310,7 +314,12 @@ async function buildBinaries(args: string[]) {
console.log(chalk.cyan("Bundling source code"))

await remove(rollupTmpDir)
await exec("npm", ["run", "rollup"], { cwd: repoRoot, stdio: "inherit", env: { GARDEN_CORE_VERSION: version } })
await exec("npm", ["run", "rollup"], {
cwd: repoRoot,
stdio: "inherit",
// We have to pass the garden version explicitly to rollup due to an issue with the json() plugin loading the wrong package.json files
env: { GARDEN_CORE_VERSION: versionInBinary },
})

await zipAndHash({
archiveName: "source",
Expand Down Expand Up @@ -428,7 +437,7 @@ async function buildBinaries(args: string[]) {
await copy(resolve(gardenSeaDir, "target", rustTarget, "release", executableFilename), executablePath)
console.log(chalk.green(` ✓ Compiled garden binary for ${targetName}`))

await target.handler({ targetName, spec: target.spec, version })
await target.handler({ targetName, spec: target.spec, version: versionInFilename })
console.log(chalk.green(" ✓ " + targetName))
}

Expand Down

0 comments on commit 8d00dc9

Please sign in to comment.