forked from ricochet-im/ricochet
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: added script to sign+tag git commit
- Loading branch information
Richard Pospesel
committed
Mar 22, 2024
1 parent
cfa98b8
commit 4eaba40
Showing
1 changed file
with
32 additions
and
0 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,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Check if at least two arguments are provided | ||
if [ "$#" -lt 2 ]; then | ||
echo "Usage: $0 channel version [commit]" | ||
exit 1 | ||
fi | ||
|
||
# Assign arguments to variables | ||
channel=$1 | ||
version=$2 | ||
commit=${3:-HEAD} | ||
|
||
# Check if the channel name is valid | ||
valid_channels=("release" "alpha") | ||
if ! [[ " ${valid_channels[@]} " =~ " $channel " ]]; then | ||
echo "Invalid channel name. Valid channel names are: ${valid_channels[*]}" | ||
exit 1 | ||
fi | ||
|
||
# Validate semantic version format | ||
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Invalid version format. Please provide semantic version (e.g., 1.2.3)" | ||
exit 1 | ||
fi | ||
|
||
# Sign and tag the specified git commit | ||
tag_name="v${version}-${channel}" | ||
commit_message="tagging ${tag_name}" | ||
|
||
echo "Signing and tagging commit $commit with tag name: ${tag_name}" | ||
git tag -s "$tag_name" "$commit" -m "$commit_message" |