mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-22 04:33:19 +03:00
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:
parent
f62519ab69
commit
8dad28e5e2
@ -1,15 +1,5 @@
|
||||
This document describes processes needed by admins of this repository.
|
||||
|
||||
# Publishing
|
||||
|
||||
Publishing speedscope is a multi-step process:
|
||||
|
||||
1. Test the release
|
||||
2. Prepare the release
|
||||
3. Publish to npm
|
||||
4. Deploy the website
|
||||
5. Upload a release to GitHub
|
||||
|
||||
At time of writing, deployment assumes you're running macOS. It probably
|
||||
works if you're on a linux, and almost definitely does not work on Windows.
|
||||
|
||||
@ -18,8 +8,9 @@ works if you're on a linux, and almost definitely does not work on Windows.
|
||||
Speedscope is tested in CI, so all the automated tests should be passing. We'll
|
||||
just be doing a few sanity checks to make sure the build & deployment machinery is working correctly.
|
||||
|
||||
Run `scripts/prepare-test-installation.sh`. This will do a mock publish &
|
||||
installation to ensure that the version we're about to publish is going to
|
||||
scripts/prepare-test-installation.sh
|
||||
|
||||
This will do a mock publish & installation to ensure that the version we're about to publish is going to
|
||||
work. At the end of this command, it should echo a `cd` command to run in your shell
|
||||
to switch to the installation directory. Something like this:
|
||||
|
||||
@ -36,58 +27,21 @@ Try importing a profile from disk via the browse button and make sure it works.
|
||||
Next, try running `bin/cli.js dist/release/perf-vertx*`. This should immediately open
|
||||
speedscope in browser, and the perf-vertx file should load immediately.
|
||||
|
||||
If everything looks good, proceed to "Prepare the release".
|
||||
## Create & publish the new release
|
||||
|
||||
## Prepare the release
|
||||
Ensure you have the Github CLI tools installed and you're authenticated. Try running the following if you're unsure:
|
||||
|
||||
1. Update the version manually in package.json (we intentionally don't use the `npm version` command)
|
||||
2. Update CHANGELOG.md to indicate the changes that were made as part of this release
|
||||
3. Commit the changes with the version name as the commit message, e.g. `git commit -m 0.6.0`
|
||||
4. `git tag` the release. We use tags like `v0.6.0`, e.g. `git tag v0.6.0`
|
||||
5. `git push && git push --tags`
|
||||
gh auth status
|
||||
npm whoami
|
||||
|
||||
## Publish to npm
|
||||
Once ready to publish, run:
|
||||
|
||||
Assuming everything went well in the previous two phases, publishing should just be
|
||||
a matter of running `npm publish`.
|
||||
scripts/publish-and-deploy.sh
|
||||
|
||||
### Verifying the publish
|
||||
## Verifying the release
|
||||
|
||||
To verify that the publish was successful, run `npm install -g speedscope`.
|
||||
To verify that the npm publish was successful, run `npm install -g speedscope`.
|
||||
Try `speedscope`, which should open speedscope in browser.
|
||||
Try `speedscope sample/profiles/stackcollapse/simple.txt`, which should immediately load the profile.
|
||||
|
||||
## Deploying the website
|
||||
|
||||
This step must follow the "Publish to npm" step, since it uses assets from
|
||||
the npm publish.
|
||||
|
||||
https://www.speedscope.app/ is hosted on GitHub pages, and is published via pushing
|
||||
to the `gh-pages` branch. The `gh-pages` branch has totally different contents than
|
||||
other branches of this repository: https://github.com/jlfwong/speedscope/tree/gh-pages.
|
||||
|
||||
It's populated by a deploy script which is invoked by running `npm run deploy` script. This populate a directory with assets pulled from npm, and
|
||||
boot a local server for you to test the compiled assets. Please do not skip
|
||||
the manual testing in this step.
|
||||
|
||||
If everything looks good, you should be able to hit Ctrl+C, and you should see this prompt:
|
||||
|
||||
```
|
||||
Commit release? [yes/no]:
|
||||
```
|
||||
|
||||
If everything looks good, type `yes` then enter. This will commit to the `gh-pages` branch, and the site should automatically deploy shortly after.
|
||||
|
||||
To check if a deploy has happened, you can check https://www.speedscope.app/release.txt
|
||||
which includes the version, the date, and the commit of the deploy.
|
||||
|
||||
## Upload a release to GitHub
|
||||
|
||||
This step must follow the "Publish to npm" step, since it uses assets from
|
||||
the npm publish.
|
||||
|
||||
To make a zipfile suitable for uploading to GitHub as a release, run `scripts/prepare-zip-file.sh`.
|
||||
|
||||
Once that's done, you should have a zip file in `dist/release/`
|
||||
|
||||
Upload that file along with changelog notes to https://github.com/jlfwong/speedscope/releases/new
|
||||
To verify the website has finished deploying, check the version number shown in the console of https://www.speedscope.app/
|
||||
|
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
|
Loading…
Reference in New Issue
Block a user