Files
lodestar/scripts/release/assert_valid_rc.mjs
Lion - dapplion 510f3108e4 Adopt gitflow for Lodestar releases (#4071)
* Adopt gitflow for Lodestar releases

* Apply feedback

* Replace most mentions of `master` with `unstable`

* Tweak various parts of RELEASE.md

* Update CI

* Tweak dev release version handling

* Tweak workflow names

* Replace `nightly` with `dev`

* Replace `beta` with `rc`

* Fix publish for rc release and stable release only

* Remove stray "beta"

* Add code examples to RELEASE.md

* Clarify publish process

* Collapse 'Alternatives considered' section

* Move 'Details' header up one level

* Clarify publishing a release

* Tweak headings

* Fix hotfix section

* More clarifications

* Update examples in RELEASE.md

* More clarifications

* Fix formatting

* Run RELEASE.md through grammarly

* Change script name to release:publish

* Add create_rc script

* Add workflow_dispatch for create RC

* Add placeholder for other scripts

* Update RELEASE.md

* Update release create rc script

* Update script instructions

* create_rc script must not be run in CI

* Update release flow

* Add publish-rc workflow

* Apply suggestions from code review

Co-authored-by: Afr Schoe <58883403+q9f@users.noreply.github.com>

Co-authored-by: Cayman <caymannava@gmail.com>
Co-authored-by: Afr Schoe <58883403+q9f@users.noreply.github.com>
2022-05-30 10:22:00 -05:00

45 lines
1.3 KiB
JavaScript

/* eslint-disable
no-console,
@typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/no-unsafe-call,
import/no-extraneous-dependencies
*/
import semver from "semver";
import {assertCommitExistsInBranch} from "./utils.mjs";
// Asserts whether a tag is a valid release candidate or not
// This script is meant to be run by a github workflow
// The output of this script is to either set github variables or not
const tag = process.env.TAG;
const commit = tag;
console.log("Tag:", tag);
// assert it matches proper format vX.X.X-rc.X
const version = semver.parse(tag);
if (!version) {
console.log("Invalid tag: unparseable version");
process.exit();
}
if (version.prerelease.length !== 2 && version.prerelease[0] !== "rc" && !Number.isInteger(version.prerelease[1])) {
console.log("Invalid tag: not a valid rc version");
process.exit();
}
// assert it exists in branch rc/vX.X.X
const rcBranch = `rc/v${version.major}.${version.minor}.${version.patch}`;
try {
assertCommitExistsInBranch(commit, rcBranch);
} catch (e) {
console.log("Invalid commit: does not exist in rc branch", rcBranch);
process.exit();
}
// success
console.log("::set-output name=is_rc::true");
console.log(`::set-output name=version::${version.version}`);