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
This commit is contained in:
39
scripts/print-changelog-update.sh
Executable file
39
scripts/print-changelog-update.sh
Executable file
@@ -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"
|
||||
51
scripts/publish-and-deploy.sh
Executable file
51
scripts/publish-and-deploy.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user