-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify release process #4030
Merged
Merged
Simplify release process #4030
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2cd9df0
Simplify release process
wemeetagain 3887140
Remove old postrelease script
wemeetagain 9dce375
Add lerna version check
wemeetagain 25c2141
Tweak RELEASE.md
wemeetagain b6b4f12
Add force-publish to lerna version command
wemeetagain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,104 @@ | ||
import {execSync} from "node:child_process"; | ||
import yargs from "yargs"; | ||
import {hideBin} from "yargs/helpers"; | ||
import inquirer from "inquirer"; | ||
|
||
// Script to make releasing easier | ||
// Run with --help to see usage | ||
|
||
const cmd = (cmd, opts={}) => execSync(cmd, {encoding: "utf8", stdio: ["pipe", "pipe", "ignore"], ...opts}).trim(); | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.usage("Release lodestar") | ||
.example([ | ||
["$0 -t v0.36.0", "Release version 0.36.0 using the current commit"] | ||
]) | ||
.options({ | ||
tag: { | ||
alias: "t", | ||
demandOption: true, | ||
type: "string", | ||
describe: "The tag to release", | ||
}, | ||
commit: { | ||
alias: "c", | ||
type: "string", | ||
default: cmd("git rev-parse --short HEAD"), | ||
describe: "The commit to tag", | ||
}, | ||
yes: { | ||
alias: "y", | ||
type: "boolean", | ||
describe: "Automatic yes to prompts" | ||
} | ||
}) | ||
.version("v0.1.0") | ||
.alias("v", "version") | ||
.alias("h", "help") | ||
.strict() | ||
.help() | ||
.argv; | ||
|
||
// Validate the supplied version | ||
const versionCaptureRegex=/^(v[0-9]+\.[0-9]+)\.[0-9]+(-beta\.[0-9]+)?$/ | ||
const versionMatch = versionCaptureRegex.exec(argv.tag); | ||
if (versionMatch == null) { | ||
console.log(`Tag must match ${versionCaptureRegex}`); | ||
process.exit(1); | ||
} | ||
|
||
const tag = argv.tag; | ||
const commit = argv.commit; | ||
const commitMessage = cmd(`git show-branch --no-name ${commit}`); | ||
// The branch is assumed from the tag | ||
const branch = `${versionMatch[1]}.x`; | ||
|
||
console.log("Tag", tag) | ||
console.log("Commit", commit, commitMessage) | ||
console.log("Branch", branch) | ||
|
||
// Ensure the branch exists | ||
try { | ||
cmd(`git show-branch --no-name ${branch}`); | ||
} catch (e) { | ||
console.log(`Branch ${branch} does not exist`); | ||
process.exit(1); | ||
} | ||
|
||
// Ensure the commit exists in the branch (last 10 commits) | ||
const last10Commits = cmd(`git log --oneline -n 10 ${branch}`); | ||
const commitMatch = last10Commits.match(commit); | ||
if (commitMatch == null) { | ||
console.log(`Commit ${commit} does not belong to branch ${branch}`); | ||
process.exit(1); | ||
} | ||
|
||
// Last chance to exit | ||
if (!argv.yes) { | ||
const input = await inquirer.prompt([ | ||
{ | ||
name: "yes", | ||
type: "confirm", | ||
message: "Do you want to proceed?", | ||
}, | ||
]); | ||
if (!input.yes) { | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// Perform release actions | ||
try { | ||
const tagCmd = `git tag -a ${tag} ${commit} -m "${tag}"`; | ||
console.log(tagCmd); | ||
cmd(tagCmd, {stdio: "pipe"}); | ||
|
||
const pushCmd = `git push origin ${tag}`; | ||
console.log(pushCmd); | ||
cmd(pushCmd, {stdio: "pipe"}); | ||
|
||
console.log("Success!"); | ||
} catch (e) { | ||
console.log(e.message); | ||
process.exit(1); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we prevent this error
TAG v0.36.1-beta.0 does not include LOCAL_VERSION 0.36.0
from https://github.com/ChainSafe/lodestar/runs/6476719731?check_suite_focus=true ?if yes, we should do a check here before we create a tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea! This condition should be checked here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script now calls
lerna version $TAG
if the tag does not matchlerna.json
(which bumps the versions in package.jsons, commits, tags and pushes).Otherwise, if the tag matches
lerna.json
, it tags and pushes manually with git.This makes it very handy to just checkout the version branch (eg: v0.36.x), cherry pick commits on top, and run the script, in the case of a beta release.
Or just checkout the version branch and run the script, in the case of a non-beta release.