mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-23 07:08:28 +00:00
Add script to update version and changelog
This commit is contained in:
parent
7a13892b3a
commit
a6d8ff8d6a
@ -1,27 +1,34 @@
|
||||
# Release Notes
|
||||
# Release
|
||||
|
||||
How to release a new version to NPM
|
||||
Releases are automatically deployed to NPM on Travis, when they are tagged. However, we have to make sure that the version in the `package.json`, and the changelog is updated.
|
||||
|
||||
## Releasing
|
||||
## Dependencies
|
||||
- [Git Extras](https://github.com/tj/git-extras/blob/master/Installation.md)
|
||||
|
||||
Run the following command to get the changelog
|
||||
## How to Release `$VERSION`
|
||||
|
||||
While on `master`, with no uncommitted changes,
|
||||
|
||||
```bash
|
||||
npm run changelog -- $VERSION
|
||||
```
|
||||
git checkout master
|
||||
|
||||
# Get the current version
|
||||
npm version
|
||||
This command does 3 things:
|
||||
1. Update the version in the `package.json`
|
||||
2. Update the changelog
|
||||
3. Creates a new commit with the changes
|
||||
|
||||
# Add the changelog for the next version
|
||||
git changelog docs/changelog.md --tag <next version>
|
||||
Now we may want to cleanup the changelog:
|
||||
|
||||
# Edit the changelog
|
||||
```bash
|
||||
vim docs/changelog.md
|
||||
|
||||
# Commit it
|
||||
git add docs/changelog.md
|
||||
git commit -m "Update changelog for \`v<next version>\`"
|
||||
git push
|
||||
git commit --amend
|
||||
```
|
||||
|
||||
Once we are satisfied,
|
||||
```bash
|
||||
git push origin master
|
||||
```
|
||||
|
||||
On [GitHub Releases](https://github.com/jiahaog/nativefier/releases), draft and publish a new release with title `Nativefier vX.X.X`.
|
||||
|
@ -22,7 +22,7 @@
|
||||
"watch": "while true ; do gulp watch ; done",
|
||||
"package-placeholder": "npm run build && node lib/cli.js http://www.bennish.net/web-notifications.html ~/Desktop --overwrite --name notification-test --icon ./test-resources/iconSampleGrey.png --inject ./test-resources/test-injection.js --inject ./test-resources/test-injection.css && open ~/Desktop/notification-test-darwin-x64/notification-test.app",
|
||||
"start-placeholder": "npm run build && electron app",
|
||||
"release": "gulp release"
|
||||
"changelog": "./scripts/changelog"
|
||||
},
|
||||
"bin": {
|
||||
"nativefier": "lib/cli.js"
|
||||
|
51
scripts/changelog
Executable file
51
scripts/changelog
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Updates the changelog and version in the package.json
|
||||
# Will also create a commit with these changes locally
|
||||
# Run `git commit --amend` after that if you wish to make changes
|
||||
#
|
||||
# Usage:
|
||||
# ./changelog "7.0.0"
|
||||
#
|
||||
# Prerequisites:
|
||||
# - On master branch
|
||||
# - No uncommitted changes
|
||||
#
|
||||
# Dependencies:
|
||||
# - git-extras https://github.com/tj/git-extras/blob/master/Installation.md
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
# Checks if we are on the master branch
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [[ "$BRANCH" != 'master' ]]; then
|
||||
echo 'ERROR: not on master branch' >&2
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Checks if there are uncommitted changes
|
||||
git diff-index --quiet HEAD -- || (echo 'ERROR: there are uncommitted changes' >&2 && exit 1)
|
||||
|
||||
VERSION="$1"
|
||||
|
||||
# Validates the $VERSION
|
||||
SEMVER_REGEX='^([0-9]+\.){2}([0-9]+)$'
|
||||
if ! [[ $VERSION =~ $SEMVER_REGEX ]]; then
|
||||
echo "ERROR: Version '$VERSION' is invalid " >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Change the version in the package.json
|
||||
cat package.json | jq ".version = \"$VERSION\"" > package.json.tmp
|
||||
|
||||
# Workaround for inplace jq editing
|
||||
mv package.json.tmp package.json
|
||||
|
||||
# Unset the editor so that git changelog does not open a editor
|
||||
EDITOR=:
|
||||
git changelog docs/changelog.md --tag \"$VERSION\"
|
||||
|
||||
# Commit these changes
|
||||
git add docs/changelog.md
|
||||
git add package.json
|
||||
git commit -m "Update changelog for \`v$VERSION\`"
|
Loading…
x
Reference in New Issue
Block a user