-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5880258
commit cf16f3b
Showing
5 changed files
with
163 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
.github/actions/goreleaser-build-sign-publish/action_utils
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env node | ||
const { execSync } = require("child_process"); | ||
|
||
function main() { | ||
const goreleaserConfig = mustGetEnv("GORELEASER_CONFIG"); | ||
const releaseType = mustGetEnv("RELEASE_TYPE"); | ||
const command = constructGoreleaserCommand(releaseType, goreleaserConfig); | ||
|
||
if (process.env.DRY_RUN) { | ||
console.log(`Generated command: ${command}`); | ||
console.log("Dry run enabled. Exiting without executing the command."); | ||
return; | ||
} else { | ||
console.log(`Executing command: ${command}`); | ||
execSync(command, { stdio: "inherit" }); | ||
} | ||
} | ||
|
||
main(); | ||
|
||
function constructGoreleaserCommand(releaseType, goreleaserConfig) { | ||
const version = getVersion(); | ||
const flags = []; | ||
|
||
checkReleaseType(releaseType); | ||
|
||
let subCmd = "release"; | ||
const splitArgs = ["--split", "--clean"]; | ||
|
||
switch (releaseType) { | ||
case "release": | ||
flags.push(...splitArgs); | ||
break; | ||
case "nightly": | ||
flags.push("--nightly", ...splitArgs); | ||
break; | ||
case "snapshot": | ||
flags.push("--snapshot", ...splitArgs); | ||
break; | ||
case "merge": | ||
flags.push("--merge"); | ||
subCmd = "continue"; | ||
break; | ||
} | ||
|
||
const flagsStr = flags.join(" "); | ||
const command = `CHAINLINK_VERSION=${version} goreleaserpro ${subCmd} --config ${goreleaserConfig} ${flagsStr}`; | ||
|
||
return command; | ||
} | ||
|
||
function checkReleaseType(releaseType) { | ||
const VALID_RELEASE_TYPES = ["nightly", "merge", "snapshot", "release"]; | ||
|
||
if (!VALID_RELEASE_TYPES.includes(releaseType)) { | ||
const validReleaseTypesStr = VALID_RELEASE_TYPES.join(", "); | ||
console.error( | ||
`Error: Invalid release type: ${releaseType}. Must be one of: ${validReleaseTypesStr}` | ||
); | ||
} | ||
} | ||
|
||
function mustGetEnv(key) { | ||
const val = process.env[key]; | ||
if (!val || val.trim() === "") { | ||
console.error(`Error: Environment variable ${key} is not set or empty.`); | ||
process.exit(1); | ||
} | ||
|
||
return val.trim(); | ||
} | ||
|
||
function getVersion() { | ||
try { | ||
const pkgPath = process.cwd() + "/package.json"; | ||
console.log("Looking for chainlink version in package.json at: ", pkgPath); | ||
const packageJson = require(pkgPath); | ||
if (!packageJson.version) { | ||
console.error( | ||
'Error: "version" field is missing or empty in package.json.' | ||
); | ||
process.exit(1); | ||
} | ||
console.log("Resolved version: ", packageJson.version); | ||
|
||
return packageJson.version; | ||
} catch (err) { | ||
console.error(`Error reading package.json: ${err.message}`); | ||
process.exit(1); | ||
} | ||
} |
Oops, something went wrong.