|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -# Path to the top level CMakeLists.txt file |
4 |
| -CMAKE_FILE="CMakeLists.txt" |
| 3 | +# Path to the version header file |
| 4 | +VERSION_FILE="include/small_vectors/version.h" |
5 | 5 |
|
6 |
| -# Extract the version number |
7 |
| -#VERSION=$(grep "VERSION" $CMAKE_FILE | head -n 1 | awk '{print $2}') |
8 |
| -#VERSION=$(grep "VERSION" $CMAKE_FILE | head -n 1 | sed -E 's/.*VERSION ([0-9]+.[0-9]+.[0-9]+).*/\1/') |
9 |
| -#VERSION=$(grep "^project(" $CMAKE_FILE | sed -n 's/.*VERSION \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p') |
10 |
| -VERSION=$(tail -n +2 $CMAKE_FILE | grep "VERSION" | head -n 1 | awk '{print $2}') |
| 6 | +# Extract the version number from the file |
| 7 | +VERSION=$(grep 'SMALL_VECTORS_VERSION' $VERSION_FILE | sed 's/.*"\(.*\)".*/\1/') |
11 | 8 |
|
12 |
| -# Check if VERSION is empty |
| 9 | +# Check if the version was successfully extracted |
13 | 10 | if [ -z "$VERSION" ]; then
|
14 |
| - echo "Version not found in $CMAKE_FILE" |
15 |
| - exit 1 |
| 11 | + echo "Error: Could not extract version from $VERSION_FILE" |
| 12 | + exit 1 |
16 | 13 | fi
|
17 | 14 |
|
18 |
| -# Prefix the version with a 'v' |
| 15 | +# Create a git tag with the extracted version, prefixed by 'v' |
19 | 16 | TAG="v$VERSION"
|
20 | 17 |
|
21 |
| -# Add a git tag |
22 |
| -git tag -a $TAG -m "Release $TAG" |
| 18 | +echo "Creating git tag: $TAG" |
23 | 19 |
|
24 |
| -# Optional: Push the tag to remote repository |
25 |
| -# git push origin $TAG |
| 20 | +# Check if the tag already exists |
| 21 | +if git rev-parse "$TAG" >/dev/null 2>&1; then |
| 22 | + echo "Error: Tag $TAG already exists." |
| 23 | + exit 1 |
| 24 | +else |
| 25 | + git tag -a "$TAG" -m "Version $VERSION" |
| 26 | + echo "Git tag $TAG created successfully." |
26 | 27 |
|
27 |
| -echo "Tag $TAG created and ready to be pushed." |
| 28 | +fi |
0 commit comments