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

V1.2.1 release notes #161

Merged
merged 2 commits into from Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions bin/bump-version
@@ -0,0 +1,28 @@
#!/bin/bash

usage() { echo "Usage: $0 -p [major | minor | patch]" 1>&2; exit 1; }

while getopts "p:" o; do
case "${o}" in
p)
patch_level=${OPTARG}
(( patch_level == 'major' || patch_level == 'minor' || patch_level == 'patch'))
Copy link
Member

Choose a reason for hiding this comment

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

I wasn't familiar with the double parentheses construct before this 😄

Could you explain to me what effect this has on the script? It look like a check to see whether the patch_level is supported, but I'm having a hard time reasoning about the impact of the check on the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is really just a defensive catch on avoiding passing a garbage argument into NPM. It also acts as a filter on arguments we don't use/permit, like prepatch.

It does mean we also prevent you actually specifying the version number to use by hand, but I consider that kind of YAGNI as in that scenario you are kind of off-script on how we work so the rest of the automated steps maybe don't help.

;;
*)
usage
;;
esac
done

echo "$patch_level"

if [[ -z "${patch_level}" ]]; then
usage
fi

new_version=$(npm version "${patch_level}" --no-git-tag-version)
git checkout -b "${new_version}"-release-notes
Copy link
Member

Choose a reason for hiding this comment

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

should we first checkout/fetch main?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question, I went back and forth on that.

I decided to punt on it on the assuming that the user could be releasing from a release/vX branch in future and if something went wrong with the checkout/fetch we'd have to be careful to catch it which felt like scope creep.

git add package.json package-lock.json
git commit -m "${new_version}"
Copy link
Member

Choose a reason for hiding this comment

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

usually we have commit as a separate step when bumping versions to double check for errors.
I notice you don't push the branch here, but maybe we should keep the existing no-commit behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a good point. My reasoning for going ahead with the commit here is that we're essentially just augmenting npm version patch which goes the commit and adds a tag, where we'd prefer a release branch for review first.

Since the package changes are explicitly checked in without anything else added, this feels like a safe assumption where little can go wrong. In dependabot-core, we hold the actual checkin as there's always the chance the Changelog script we wrote ourselves misfires for example 🤔


echo "Branch prepared for ${new_version}"
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "dependabot-pull-request-action",
"version": "1.1.1",
"version": "1.2.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

v1.2.0 does exist, the package.json just didn't get bumped as our versioning is done via Releases.

I added a script wrapper for npm version we use on another action to make this a little smoother.

Copy link
Member

Choose a reason for hiding this comment

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

Oops that was my bad. Nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I only caught it as I'd left updater-action at v0.0.0 through about six releases 😬

"description": "Parse Dependabot commit metadata to automate PR handling",
"main": "dist/index.js",
"scripts": {
Expand Down