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

Simplify bin/bump-version #368

Merged
merged 1 commit into from
May 18, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
```bash
git checkout main
git pull
bin/bump-version -p patch # patch | minor | major
bin/bump-version minor # major | minor | patch
```
- Merge the PR after getting it reviewed
- Create a new release tagged as `v1.X.X` format:
Expand Down
38 changes: 13 additions & 25 deletions bin/bump-version
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
#!/bin/bash

usage() { echo "Usage: $0 -p [major | minor | patch]" 1>&2; exit 1; }
usage() { echo "Usage: $0 [ 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'))
;;
*)
usage
;;
esac
done
version_type=$1
if [ "$version_type" == "major" ] || [ "$version_type" == "minor" ] || [ "$version_type" == "patch" ]; then
new_version=$(npm version "$version_type" --no-git-tag-version)
echo "$new_version"

echo "$patch_level"

if [[ -z "${patch_level}" ]]; then
git checkout -b "${new_version}"-release-notes
git add package.json package-lock.json
echo "Creating commit / PR linking to the releases notes URL."
echo "This URL will 404 until the release is actually tagged, which you should do as soon as the PR is merged."
git commit -m "${new_version}" -m "Release notes: https://github.com/dependabot/fetch-metadata/releases/tag/v${new_version}"
gh pr create --fill # `fill` re-uses the title / body from the commit
echo "PR created for ${new_version}"
else
usage
fi

new_version=$(npm version "${patch_level}" --no-git-tag-version)
git checkout -b "${new_version}"-release-notes
git add package.json package-lock.json

echo "Creating commit / PR linking to the releases notes URL."
echo "This URL will 404 until the release is actually tagged, which you should do as soon as the PR is merged."
git commit -m "${new_version}" -m "Release notes: https://github.com/dependabot/fetch-metadata/releases/tag/v${new_version}"
gh pr create --fill # `fill` re-uses the title / body from the commit
echo "PR created for ${new_version}"