-
Notifications
You must be signed in to change notification settings - Fork 168
Generate release notes from commit messages #536
Conversation
|
@ERKarl thanks for the PR. The main issue is updating the Github Release notes text via api. Perhaps there's a curl command that can be called with a |
|
Gotcha, I'll see what I can do about that. |
|
@tanx I've updated the script to hit the GitHub releases endpoint to create a new draft release and include the commit messages as release notes. Usage:
|
tanx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ERKarl awesome! Thanks so much. Just a few questions...
release.sh
Outdated
| git fetch --tags | ||
|
|
||
| # generate boilerplate release notes from commits | ||
| RELEASE_NOTES="$(git log $(git describe --tags --abbrev=0)..HEAD --pretty='* %s (%h)\n')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there also a way to generate the logs only from merged PR messages? I'm open to adopting a certain syntax/style for merge/commit messages if necessary.
release.sh
Outdated
| echo Current release: `sed -n 's/.*"version": "\(.*\)".*/\1/p' ${PACKAGE}` | ||
| exit 1 | ||
| fi | ||
| RELEASE=$1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand this block. Shouldn't the version provided in the package.json be enough to identify the corresponding github release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, new version name must be provided as an argument. If you don't provide one the script will exit printing you the current version name for convenience.
➜ lightning-app git:(release-notes) ✗ ./release.sh
You must provide only a release version!
Current release: 0.2.0-prealpha.24
➜ lightning-app git:(release-notes) ✗ ./release.sh 0.2.0-prealpha.25
This gives us fine-grained control over the future version numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git log $(git describe --tags --abbrev=0)..HEAD on line 31 gets us the commits from previous tag to HEAD. I've also added the missing missing code (line 22->25) to update package.json with the specified new version and commit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, new version name must be provided as an argument. If you don't provide one the script will exit printing you the current version name for convenience.
Just to clarify, I run npm version 0.2.2-alpha locally and then push the git tag and updates package.json to the master. So the package.json already has to new version before the release is triggered on travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks for clearing this up. I'll make the necessary changes. The script will then just take the version from package.json and generate a draft release notes to Github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Sounds good. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tanx updated.
With the updated script the workflow is the following:
git checkout master
git pull
git fetch --tags
npm version 0.2.2-alpha
git push
git push --tags
./release-notes.sh
We can even automate this a little further... 🤔
release.sh
Outdated
| curl -H "Content-Type: application/json" \ | ||
| -H "Authorization: token $GH_TOKEN" \ | ||
| --data @$TEMP_DATA_JSON \ | ||
| $GITHUB_API_ENDPOINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 👍
|
@tanx sorry for the delay in applying feedback to this PR (Lightning Hackday & traveling). I took a look at various release generator libraries and ended up not using them. I'd rather avoid adding dependencies (even The script now generates release notes only from merged PR messages and adds a clickable link to the corresponding commit. Please let me know when it looks good so that I can squash the commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @ERKarl. Looks really good. The script will run after the build_app.sh script in the travis deploy phase:
Lines 33 to 39 in 6ff1e08
| deploy: | |
| provider: script | |
| script: ./assets/script/build_app.sh | |
| skip_cleanup: true | |
| on: | |
| repo: lightninglabs/lightning-app | |
| tags: true |
Have you tried what happens when there is already a draft for the release there? Because the binaries should already have been pushed to the same draft before this new script get executed.
release-notes.sh
Outdated
| CURRENT_TAG=v${RELEASE_NAME} | ||
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1)) | ||
| RELEASE_NOTES="$(git log ${PREVIOUS_TAG}..HEAD --merges --pretty='* %b [%h](http://github.com/lightninglabs/lightning-app/commit/%H)\n')" | ||
| DATA_JSON='{"tag_name": "'"$CURRENT_TAG"'", "name": "'"$RELEASE_NAME"'", "body": "'"$RELEASE_NOTES"'", "prerelease": true, "draft": true}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI we don't publish as prerelease anymore.
@tanx it looks like it currently creates a new draft with the same name. Ideally I'd like it to append to the existing draft. |
|
@tanx I've updated the release-notes script to update an existing draft release generated by Travis. I got fed up with bash and refactored the script in JavaScript. Didn't use NodeJS Usage: |
Ok. Just curious about the choice of node since the code calls shell commands via node now. Did you run into some issue with bash? The shell script before actually looked much more concise and easier to read tbh. |
Appends release notes to an existing Github draft release. Release notes are generated from the merge commits since the last tag.
|
@tanx In hindsight the shell script is probably a little easier to read. I've reverted back the changes and added the update existing release functionality to the shell script. For comparison the JS version is available here. |
|
@ERKarl sorry for the late response. Back from vacation. I'll test this shortly. BTW there's a CLA bot now :) |



#480
This PR will add a
generate-release-notesscript that will generateCHANGELOG.mdbased on new commits since the latest tag.I didn't add automatic tag publishing because we might want to edit the release notes manually before publishing.