Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release and mergeback workflows #510

Merged
merged 3 commits into from
May 27, 2021

Conversation

aeisenberg
Copy link
Contributor

This commit ensures that the changelog is updated before a release with
the correct date and version.

Also, after a release, a mergeback PR is created to ensure that the
changelog update and version bump is available in main.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.

@aeisenberg aeisenberg marked this pull request as draft May 19, 2021 20:53
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 3 times, most recently from fe1dfe9 to 5100571 Compare May 19, 2021 21:29
@aeisenberg aeisenberg marked this pull request as ready for review May 19, 2021 21:35
@aeisenberg
Copy link
Contributor Author

You can try out the new update-release-branch behaviour by running that workflow on this branch. You can see that it updates the changelog file with the expected text.

I have not been able to try the post-release-mergeback workflow yet. Since it's not merged into main, I can't run it as workflow dispatch. If it looks ok, can we merge, and then I will test it out?

@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch from 5100571 to 98bd32a Compare May 19, 2021 21:59
@aeisenberg aeisenberg marked this pull request as draft May 19, 2021 22:03
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 3 times, most recently from 0104591 to cc2df76 Compare May 19, 2021 22:18
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch from cc2df76 to b3104f5 Compare May 19, 2021 22:20
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch from b3104f5 to f03bccd Compare May 19, 2021 22:26
@aeisenberg aeisenberg requested review from adityasharad and a team May 19, 2021 22:26
Base automatically changed from aeisenberg/changelog to main May 19, 2021 22:41
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 10 times, most recently from 133f209 to 14f5cf4 Compare May 19, 2021 23:27
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 2 times, most recently from 3e07ee2 to 99dd264 Compare May 20, 2021 16:19
.github/update-release-branch.py Outdated Show resolved Hide resolved
@@ -71,6 +81,13 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
body += ' - ' + get_truncated_commit_message(commit)
body += ' (@' + commit.author.login + ')'

body += '\n\nPlease review the following:\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: consider creating a list of lines, and then calling '\n'.join(lines).

.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Show resolved Hide resolved
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 2 times, most recently from 17c3445 to dda41ec Compare May 21, 2021 17:02
@aeisenberg aeisenberg marked this pull request as draft May 21, 2021 17:04
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 7 times, most recently from c56582a to 87926c7 Compare May 21, 2021 17:44
git commit -m "Update changelog and version after $VERSION"

git push origin "$NEW_BRANCH"
gh pr create --head "$NEW_BRANCH" --base "$BASE_BRANCH" --title "$PR_TITLE" --body "$PR_BODY" --reviewer "$DEFAULT_REVIEWER"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider making this a draft PR when "$GITHUB_EVENT_NAME" == "pull_request".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea.

@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch 2 times, most recently from 9190040 to 1efbebf Compare May 21, 2021 17:50
@aeisenberg aeisenberg marked this pull request as ready for review May 21, 2021 17:55
This commit ensures that the changelog is updated before a release with
the correct date and version.

Also, after a release, a mergeback PR is created to ensure that the
changelog update and version bump is available in main.
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch from 1efbebf to 800a951 Compare May 21, 2021 18:04
@aeisenberg
Copy link
Contributor Author

Here's the latest PR that gets created: #526

Copy link
Contributor

@adityasharad adityasharad left a comment

Choose a reason for hiding this comment

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

Looks good. A few minor comments, feel free to merge once addressed.

@@ -9,7 +9,8 @@
"test-debug": "ava src/** --serial --verbose --timeout=20m",
"lint": "eslint --report-unused-disable-directives --max-warnings=0 . --ext .js,.ts",
"lint-fix": "eslint --report-unused-disable-directives --max-warnings=0 . --ext .js,.ts --fix",
"removeNPMAbsolutePaths": "removeNPMAbsolutePaths . --force"
"removeNPMAbsolutePaths": "removeNPMAbsolutePaths . --force",
"version": "cd runner && npm version patch && git add ."
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only for the runner? Should it also update the Action's package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not exactly. This script ensures that when npm version ... is called, the version script runs and that also triggers the npm version on the runner. So, both will be updated in tandem.

See npm help version

If preversion, version, or postversion are in the scripts property of the package.json, they will be executed as part of running npm version.
...
4. Run the version script. These scripts have access to the new version in package.json...

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. So calling npm version at the root will then invoke this script, which bumps the version in the runner. Makes sense.

Consider avoiding the git add . here, and keeping that in the Actions workflow instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By running git add ., this ensures that the version changes to the runner get included in the same commit as the version changes to the containing action. I could run git commit --amend in the workflow, but that seems messier if someone is running the npm version command manually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Do you know which file it will touch? Perhaps just add the package.json file then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

package.json and package-lock.json. It's pretty safe running add . since the initial npm version will fail if the working directory is not clean. I have a slight preference for keeping the . since this will be more future proof if npm version ever does start touching different files.

Also note that the invocation of npm version patch in the runner directory doesn't create a commit since commits are only created if the package.json is in the root of the git repo.

.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Outdated Show resolved Hide resolved
.github/workflows/post-release-mergeback.yml Show resolved Hide resolved
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch from 2c06220 to bdc51ca Compare May 27, 2021 19:26
Ensures that the runner version is bumped along with the action version.
@aeisenberg aeisenberg force-pushed the aeisenberg/update-changelog-on-release branch from bdc51ca to ea89b06 Compare May 27, 2021 19:32
Copy link
Contributor

@adityasharad adityasharad left a comment

Choose a reason for hiding this comment

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

Update from main and :shipit:!

@aeisenberg aeisenberg enabled auto-merge May 27, 2021 20:12
@aeisenberg aeisenberg merged commit 2ccefac into main May 27, 2021
@aeisenberg aeisenberg deleted the aeisenberg/update-changelog-on-release branch May 27, 2021 20:22
@github-actions github-actions bot mentioned this pull request May 31, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants