-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathversion_bump.sh
More file actions
executable file
·65 lines (55 loc) · 1.7 KB
/
version_bump.sh
File metadata and controls
executable file
·65 lines (55 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# SPDX-FileCopyrightText: GitHub, Inc.
# SPDX-License-Identifier: MIT
# Script for updating the version number. Call it like this:
#
# ./release_tools/version_bump.sh minor
#
# It uses `hatch version` to update the version number. Use
# major/minor/micro to determine which part of the version number to
# bump. It creates a new branch and commits the version number
# change.
#
# This script does not push the change to GitHub, so you need to do
# that manually.
if [[ $# -eq 0 ]] ; then
echo 'usage: ./release_tools/version_bump.sh [ARG]'
echo 'ARG is passed to the hatch version command to bump the version number.'
echo 'ARG is usually "major", "minor", or "micro".'
exit 0
fi
# Check that the main branch is checked out.
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ] ; then
echo "Please check out the main branch before running this command."
exit 1
fi
# Check no uncommitted changes.
git update-index --refresh
if ! git diff-index --quiet HEAD -- ; then
echo "There are uncommitted file changes. Aborting."
exit 1
fi
# Bump version number
if ! hatch version "$@" ; then
echo "Failed to update version"
exit 1
fi
# Read new version number
if ! NEW_VERSION_NUMBER=$(hatch version) ; then
echo "Failed to retrieve version number."
exit 1
fi
# Create new branch
if ! git checkout -b "version-$NEW_VERSION_NUMBER" ; then
echo "Creating the branch failed."
git restore .
exit 1
fi
# Commit the version number change.
if ! git commit -a -m "Version $NEW_VERSION_NUMBER" ; then
echo "git commit failed"
exit 1
fi
echo
echo "I have updated the version number locally."
echo "The branch is ready for you to push to GitHub and create a pull request."