-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bin/annotate.sh and document usage
- Loading branch information
1 parent
aba079b
commit e043d45
Showing
2 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Annotate a tag from Github | ||
# FAQ: Github releases create annotated (not lightweight) tags | ||
# SEE: https://github.com/orgs/community/discussions/4924 | ||
|
||
# Whether string is a valid SemVer version | ||
is_valid_semver() { | ||
local version=$1 | ||
# SemVer regex pattern (simplified for illustration) | ||
local semver_pattern="^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" | ||
[[ $version =~ $semver_pattern ]] | ||
} | ||
|
||
# Is argument (string) provided? | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <version_string>" | ||
exit 1 | ||
fi | ||
|
||
# Capture arguments | ||
version_string=$1 | ||
|
||
# Is string a valid SemVer version? | ||
if ! is_valid_semver "$version_string"; then | ||
echo "Error: Invalid SemVer format. Please provide a valid version string like '3.11.6' or 'v3.12.0-beta.3' or 'v3.6.0-8-gd1dbcab'." | ||
exit 1 | ||
fi | ||
|
||
# Annotate the tag | ||
git pull | ||
git checkout "$version_string" | ||
git tag -d "$version_string" | ||
git tag -a "$version_string" -m "chore: $version_string" | ||
|
||
# Report success | ||
echo "Annotated tag \"$version_string\"." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters