Skip to content

Commit 51f0d23

Browse files
authored
Add scripts for bumping the connector version and tagging the code (#294)
1 parent 027c0b1 commit 51f0d23

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed

scripts/bump_version.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Copyright © 2025 Meroxa, Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
# Get the directory where the script is located
19+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
20+
21+
source "${SCRIPT_DIR}/common.sh"
22+
23+
TAG=$1
24+
25+
if ! check_semver "$TAG"; then
26+
echo "$TAG is NOT a valid semver string"
27+
exit 1
28+
fi
29+
30+
# Check if yq is installed
31+
if ! command -v yq &> /dev/null; then
32+
echo "Error: yq is not installed. Please install it and try again."
33+
exit 1
34+
fi
35+
36+
V_TAG="v$TAG"
37+
38+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
39+
CURRENT_TAG=$(get_spec_version connector.yaml)
40+
MSG="You are about to bump the version from ${CURRENT_TAG} to ${V_TAG} on branch '${BRANCH}'.\n"
41+
while true; do
42+
printf "${MSG}"
43+
read -p "Are you sure you want to continue? [y/n]" yn
44+
echo
45+
case $yn in
46+
[Yy]* )
47+
BRANCH_NAME="update-version-$V_TAG"
48+
git checkout -b "$BRANCH_NAME"
49+
yq e ".specification.version = \"${V_TAG}\"" -i connector.yaml
50+
git commit -am "Update version to $V_TAG"
51+
git push origin "$BRANCH_NAME"
52+
53+
# Check if gh is installed
54+
if command -v gh &> /dev/null; then
55+
echo "Creating pull request..."
56+
gh pr create \
57+
--base main \
58+
--title "Update version to $V_TAG" \
59+
--body "Automated version update to $V_TAG" \
60+
--head "$BRANCH_NAME"
61+
else
62+
echo "GitHub CLI (gh) is not installed. To create a PR, please install gh or create it manually."
63+
echo "Branch '$BRANCH_NAME' has been pushed to origin."
64+
fi
65+
66+
echo "Once the change has been merged, you can use scripts/tag.sh to push a new tag."
67+
break;;
68+
[Nn]* ) exit;;
69+
* ) echo "Please answer yes or no.";;
70+
esac
71+
done

scripts/common.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Copyright © 2025 Meroxa, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
check_semver() {
18+
local version=$1
19+
local SV_REGEX="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$"
20+
21+
if ! [[ $version =~ $SV_REGEX ]]; then
22+
echo "$version is NOT a valid semver string"
23+
return 1
24+
fi
25+
return 0
26+
}
27+
28+
get_spec_version() {
29+
local yaml_file=$1
30+
31+
if command -v yq &> /dev/null; then
32+
yq '.specification.version' "$yaml_file"
33+
else
34+
sed -n '/specification:/,/version:/ s/.*version: //p' "$yaml_file" | tail -1
35+
fi
36+
}

scripts/tag.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Copyright © 2025 Meroxa, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Get the directory where the script is located
18+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
19+
20+
source "${SCRIPT_DIR}/common.sh"
21+
22+
HAS_UNCOMMITTED=$(git status --porcelain=v1 2>/dev/null | wc -l | awk '{print $1}')
23+
if (( $HAS_UNCOMMITTED != 0 )); then
24+
echo "You have uncommitted changes, cannot tag."
25+
exit 1
26+
fi
27+
28+
LAST_COMMIT=$(git log -1 --oneline)
29+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
30+
CURRENT_TAG=$(git describe --tags --abbrev=0)
31+
V_TAG=$(get_spec_version connector.yaml)
32+
MSG="You are about to bump the version from ${CURRENT_TAG} to ${V_TAG}.
33+
Current commit is '${LAST_COMMIT}' on branch '${BRANCH}'.
34+
The release process is automatic and quick, so if you make a mistake,
35+
everyone will see it very soon."
36+
37+
while true; do
38+
printf "${MSG}"
39+
read -p "Are you sure you want to continue? [y/n]" yn
40+
echo
41+
case $yn in
42+
[Yy]* )
43+
git tag -a $V_TAG -m "Release: $V_TAG"
44+
git push origin $V_TAG
45+
break;;
46+
[Nn]* ) exit;;
47+
* ) echo "Please answer yes or no.";;
48+
esac
49+
done

0 commit comments

Comments
 (0)