-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate more of the release process (#439)
The publish, deploy, and release process is annoying enough at the moment that I avoid doing it frequently. Let's automate most of it to reduce the friction
- Loading branch information
Showing
3 changed files
with
102 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Print changes since the last tagged release in a format to match CHANGELOG.md | ||
|
||
set -euo pipefail | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "Usage: $0 <version>" | ||
echo "e.g. $0 1.15.2" | ||
exit 1 | ||
fi | ||
version="$1" | ||
|
||
|
||
# Get the most recent tagged commit that is an ancestor of HEAD | ||
tagged_commit=$(git log --simplify-by-decoration --oneline --decorate | grep -E '^\w+ \(tag: .+\) .+$' | head -n1 | cut -d' ' -f 1) | ||
|
||
gitlog=$(git log --graph --pretty=format:"%s" --abbrev-commit "$tagged_commit"..HEAD) | ||
|
||
version="$1" | ||
|
||
current_date=$(date +%Y-%m-%d) | ||
echo "## [$version] - $current_date" | ||
echo | ||
|
||
while IFS= read line; do | ||
message=$(echo "$line" | sed 's/^* //g') | ||
message_without_pr_num=$(echo "$message" | sed 's/ (#[0-9][0-9]*)//g') | ||
|
||
pr_number=$(echo "$message" | grep -Eo '#[0-9]+' | grep -Eo '[0-9]+'; true) | ||
|
||
if [[ -n "$pr_number" ]]; then | ||
author=$(gh pr view $pr_number --json author -q ".author.login") | ||
pr_link="https://github.com/jlfwong/speedscope/pull/$pr_number" | ||
echo "- $message_without_pr_num [[#$pr_number]($pr_link)] (by @$author)" | ||
else | ||
echo "- $message_without_pr_num" | ||
fi | ||
done <<< "$gitlog" |
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,51 @@ | ||
#!/bin/bash | ||
|
||
# Run the full release process. This means... | ||
# - Bumping the version in package.json | ||
# - Updating the changelog | ||
# - Commiting and tagging the release | ||
# - Pushing to Github | ||
# - Publishing a new version to npm | ||
# - Deploying the website | ||
# - Create a new release in Github with the zip-file standalone version | ||
|
||
set -euxo pipefail | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "Usage: $0 <minor | patch | version>" | ||
echo "e.g. $0 patch" | ||
exit 1 | ||
fi | ||
version_arg="$1" | ||
|
||
# Bump versions in package.json and package-lock.json, but don't commit or make tags yet | ||
version=$(npm version "$version_arg" --no-git-tag-version --no-commit-hooks | sed 's/^v//g') | ||
tagname="v$version" | ||
|
||
script_dir=$(dirname "$0") | ||
|
||
# Prepend the changelog update to CHANGELOG.md | ||
changelog_update=$("$script_dir/print-changelog-update.sh" "$version") | ||
|
||
echo -e "$changelog_update\n" > CHANGELOG.md.new | ||
cat CHANGELOG.md >> CHANGELOG.md.new | ||
mv CHANGELOG.md.new CHANGELOG.md | ||
|
||
# Commit and tag the release | ||
git add CHANGELOG.md package.json package-lock.json | ||
git commit -m "$version" | ||
git tag "$tagname" | ||
|
||
# Push to Github | ||
git push | ||
git push --tags | ||
|
||
# Publish to npm | ||
npm publish | ||
|
||
# Create a new release on Github | ||
"$script_dir/prepare-zip-file.sh" | ||
gh release create "$tagname" --title "$tagname" --notes "$changelog_update" --attach "dist/release/speedscope-$version.zip" | ||
|
||
# Deploy the website | ||
npm run deploy |