Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Conversation

@ghost
Copy link

@ghost ghost commented Aug 17, 2018

#480

This PR will add a generate-release-notes script that will generate CHANGELOG.md based 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.

@tanx
Copy link
Contributor

tanx commented Aug 20, 2018

@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 GH_TOKEN env var?

@ghost
Copy link
Author

ghost commented Aug 20, 2018

Gotcha, I'll see what I can do about that.

@ghost
Copy link
Author

ghost commented Aug 21, 2018

@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.

screen shot 2018-08-21 at 16 29 35

Usage: GH_TOKEN=123 ./release.sh v2.0

GH_TOKEN can be generated from github.com/settings/tokens and has to have Full control of private repositories permission.

@tanx tanx self-requested a review August 27, 2018 09:43
@tanx tanx added the build label Aug 27, 2018
Copy link
Contributor

@tanx tanx left a 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')"
Copy link
Contributor

@tanx tanx Aug 27, 2018

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
Copy link
Contributor

@tanx tanx Aug 27, 2018

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?

Copy link
Author

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.

Copy link
Author

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.

Copy link
Contributor

@tanx tanx Sep 13, 2018

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.

Copy link
Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Sounds good. Thanks

Copy link
Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍

@ghost
Copy link
Author

ghost commented Sep 5, 2018

@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 dev only) to the project unless absolutely necessary.

The script now generates release notes only from merged PR messages and adds a clickable link to the corresponding commit.
screen shot 2018-09-05 at 22 47 54

Please let me know when it looks good so that I can squash the commits.

Copy link
Contributor

@tanx tanx left a 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:

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}'
Copy link
Contributor

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.

@ghost
Copy link
Author

ghost commented Sep 14, 2018

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.

@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.

@ghost
Copy link
Author

ghost commented Sep 14, 2018

@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 https API because I already had the curl commands.

Usage: node release-notes.js

screen shot 2018-09-14 at 16 27 49

@tanx
Copy link
Contributor

tanx commented Sep 14, 2018

@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 https API because I already had the curl commands.

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.
@ghost
Copy link
Author

ghost commented Sep 15, 2018

@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.

@tanx
Copy link
Contributor

tanx commented Oct 1, 2018

@ERKarl sorry for the late response. Back from vacation. I'll test this shortly. BTW there's a CLA bot now :)

@tanx tanx merged commit 8efd57c into lightninglabs:master Oct 2, 2018
@ghost ghost deleted the release-notes branch October 2, 2018 17:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant