Skip to content

Commit

Permalink
Update hack/release to accept branch argument and update doc accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
wongma7 committed Dec 9, 2021
1 parent 2ed8b98 commit beefd52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 8 additions & 7 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Amazon Elastic Block Store (EBS) CSI driver Release Process
NOTE: Your GitHub account must have the required permissions and you must have generated a GitHub token.

## Choose the release version and release branch

Expand All @@ -19,16 +18,18 @@ NOTE: Your GitHub account must have the required permissions and you must have g

## Create the release commit in the release branch

Proceed according to the version and branch you chose above, for example version v1.3.2 and branch release-1.3.
Checkout the release branch you chose above, for example `git checkout release-1.3`.

### Update `CHANGELOG-0.x.md`
We need to generate the CHANGELOG for the new release by running `./hack/release`. You need to pass previous release tag to generate the changelog.

1. Generate a Personal Access Token with `repos` permissions.
2. Run hack/release with arguments according to the version and branch you chose above:
- `--since`: the release version immediately preceding your chosen release version and the chosen release branch to generate the changelog. For example, for v1.3.2 pass `--since v1.3.1`.
- `--branch`: the release branch you chose. For example, for v1.3.2 pass `--branch release-1.3`.
```
python3 hack/release --github-user=ayberk --github-token=$GITHUB_TOKEN note --since <previous_version_tag>
python3 hack/release --github-user=$GITHUB_USER --github-token=$GITHUB_TOKEN note --since $PREVIOUS_VERSION --branch $BRANCH
```

This will print the CHANGELOG to stdout. You should create a new section for the new version and copy the output there.
This will print the CHANGELOG to stdout.
3. Create a new section for the new version and copy the output there. Organize and prune the CHANGELOG at your own discretion. For example, release commits like "Release v1.3.3" are not useful and should be removed or put in a "Misc." section.

### Update `docs/README.md`
Search for any references to the previous version on the README, and update them if necessary.
Expand Down
14 changes: 8 additions & 6 deletions hack/release
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class Github:
self._user = user
self._token = token

def get_commits(self, repo, since):
resp = requests.get('{}/repos/{}/compare/{}...master'.format(self._url, repo, since),
def get_commits(self, repo, since, branch):
resp = requests.get('{}/repos/{}/compare/{}...{}'.format(self._url, repo, since, branch),
auth=(self._user, self._token))
jsonResp = json.loads(resp.content)
return jsonResp['commits']
Expand All @@ -79,9 +79,9 @@ class Github:
jsonResp = json.loads(resp.content)
return jsonResp

def print_release_note(self, repo, since):
def print_release_note(self, repo, since, branch):
# remove merge commits
commits = self.get_commits(repo, since)
commits = self.get_commits(repo, since, branch)
commits = filter(lambda c: not c['commit']['message'].startswith('Merge pull request'), commits)
pr_numbers = set()
for commit in commits:
Expand All @@ -106,11 +106,12 @@ def print_sha(args):
def print_notes(args):
repo = args.repo
since = args.since
branch = args.branch
user = args.github_user
token = args.github_token

g = Github(user, token)
g.print_release_note(repo, since)
g.print_release_note(repo, since, branch)

if __name__=="__main__":
parser = argparse.ArgumentParser(description='Generate release CHANGELOG')
Expand All @@ -121,7 +122,8 @@ if __name__=="__main__":
subParsers = parser.add_subparsers(title='subcommands', description='[note|sha]')

noteParser = subParsers.add_parser('note', help='generate release notes')
noteParser.add_argument('--since', metavar='since', type=str, required=True, help='since version tag')
noteParser.add_argument('--since', metavar='since', type=str, required=True, help='since version tag, e.g. if releasing v1.3.5 then set this to v1.3.4')
noteParser.add_argument('--branch', metavar='branch', type=str, required=True, help='release branch, e.g. if releasing v1.3.5 then set this to release-1.3')
noteParser.set_defaults(func=print_notes)

shaParser = subParsers.add_parser('sha', help='generate SHA for released version tag')
Expand Down

0 comments on commit beefd52

Please sign in to comment.