Add GoReleaser configuration and version command
Some checks failed
goreleaser / goreleaser (push) Failing after 5m46s

This commit is contained in:
2025-05-23 15:41:54 +02:00
parent e1f7604439
commit a806b97b9b
5 changed files with 437 additions and 3 deletions

View File

@@ -28,8 +28,12 @@ if [ -n "$(git status --porcelain)" ]; then
POSTFIX=" (dirty)"
fi
# Format a clean version string for the build
VERSION=$(echo "$BRANCH" | sed 's/^v//')
BUILD_DATE=$(date -u '+%Y-%m-%d %H:%M:%S')
printfe "%s\n" "cyan" "Building $BINARY_NAME binary for $BRANCH ($LATEST_COMMIT_HASH)$POSTFIX..."
go build -o $BINARY_PATH
go build -ldflags="-X 'git.mvl.sh/vleeuwenmenno/sshtunnel/cmd.Version=$BRANCH' -X 'git.mvl.sh/vleeuwenmenno/sshtunnel/cmd.BuildDate=$BUILD_DATE'" -o $BINARY_PATH
if [ $? -ne 0 ]; then
printf "\033[0;31m"
@@ -39,9 +43,9 @@ if [ $? -ne 0 ]; then
fi
# Put tag and hash in .sshtunnel_version file
echo "$BRANCH ($LATEST_COMMIT_HASH)$POSTFIX" > $BINARY_PATH_VERSION
echo "$BRANCH" > $BINARY_PATH_VERSION
printfe "%s\n" "cyan" "Generating Bash completion script..."
printfe "%s\n" "cyan" "Generating completion scripts..."
$BINARY_PATH completion bash > $COMPLETION_SCRIPT
printfe "%s\n" "green" "Bash completion script installed to $COMPLETION_SCRIPT."