From e145d652134fc8cd2702ec5cb5afa5f707102047 Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Fri, 5 Aug 2022 11:40:58 +0200 Subject: [PATCH] feat: Added release guide. --- Makefile | 13 +++++++++- docs/releasing.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 docs/releasing.md diff --git a/Makefile b/Makefile index 852385aa..2edbb9f2 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,17 @@ release: generate cp -rf README.md release/ cp -rf LICENSE-MIT release/ +github-release: + @echo "${RELEASE}" | grep -q -e "^v" || { echo "Please make sure version starts with \"v\"."; exit 1; } + gh release create -d --generate-notes ${RELEASE} + @sleep 5 + gh release view ${RELEASE} -t "{{.body}}" --json body > RELEASE_NOTES + gh release delete ${RELEASE} -y + gh release create -F RELEASE_NOTES -d --title ${RELEASE} --target release release/${RELEASE} + @sleep 5 + rm -rf RELEASE_NOTES + open $$(gh release view release/${RELEASE} --json url -t "{{.url}}") + postversion: release git fetch origin git push @@ -78,4 +89,4 @@ install: build/libllhttp.a build/libllhttp.so $(INSTALL) -C build/libllhttp.a $(DESTDIR)$(LIBDIR)/libllhttp.a $(INSTALL) build/libllhttp.so $(DESTDIR)$(LIBDIR)/libllhttp.so -.PHONY: all generate clean release +.PHONY: all generate clean release postversion github-release diff --git a/docs/releasing.md b/docs/releasing.md new file mode 100644 index 00000000..f83e0f7c --- /dev/null +++ b/docs/releasing.md @@ -0,0 +1,65 @@ +# How to release a new version of llhttp + +## What does releasing involves? + +These are the required steps to release a new version of llhttp: + +1. Increase the version number. +2. Build it locally. +3. Create a new build and push it to GitHub. +4. Create a new release on GitHub release. + +> Do not try to execute the commands in the Makefile manually. This is really error-prone! + +## Which commands to run? + +First of all, make sure you have [GitHub CLI](https://cli.github.com) installed and configured. While this is not strictly necessary, it will make your life way easier. + +As a preliminary check, run the build command and execute the test suite locally: + +``` +npm run build +npm test +``` + +If all goes good, you are ready to go! + +To release a new version of llhttp, first increase the version using `npm` and make sure it also execute the `postversion` script. Unless you have some very specific setup, this should happen automatically, which means the following command will suffice: + +``` +npm version [major|minor|patch] +``` + +The command will increase the version and then will create a new release branch on GitHub. + +> Even thought there is a package on NPM, it is not updated anymore. NEVER RUN `npm publish`! + +It's now time to create the release on GitHub. If you DON'T have GitHub CLI available, skip to the next section, otherwise run the following command: + +``` +npm run github-release +``` + +This command will create a draft release on GitHub and then show it in your browser so you can review and publish it. + +Congratulation, you are all set! + +## Create a GitHub release without GitHub CLI + +> From now on, `$VERSION` will be the new version you are trying to create, including the leading letter, for instance `v6.0.9`. + +If you don't want to or can't use GitHub CLI, you can still create the release on GitHub following this procedure. + +1. Go on GitHub and start creating a new release which targets tag `$VERSION`. Generate the notes using the `Generate release notes` button. + +2. At the bottom of the generated notes, make sure the previous and current version in the notes are correct. + + The last line should be something like this: `**Full Changelog**: https://github.com/nodejs/llhttp/compare/v6.0.8...v6.0.9` + + In this case it says we are creating release `v6.0.9` and we are showing the changes between `v6.0.8` and `v6.0.9`. + +3. Change the target of the release to point to tag `release/$VERSION`. + +4. Review and then publish the release. + +Congratulation, you are all set! \ No newline at end of file diff --git a/package.json b/package.json index 3f73b5f7..272a93dc 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "lint": "tslint -c tslint.json bin/*.ts src/*.ts src/**/*.ts test/*.ts test/**/*.ts", "mocha": "mocha --timeout=10000 -r ts-node/register/type-check --reporter progress test/*-test.ts", "test": "npm run mocha && npm run lint", - "postversion": "TAG=`node -e \"process.stdout.write(require('./package').version)\"` make -B postversion" + "postversion": "TAG=`node -e \"process.stdout.write(require('./package').version)\"` make -B postversion", + "github-release": "RELEASE=`node -e \"process.stdout.write('v' + require('./package').version)\"` make github-release" }, "repository": { "type": "git",