This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release.sh: fix build versioning (#108)
- Loading branch information
Showing
3 changed files
with
38 additions
and
84 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,34 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
IFS=".$IFS" read -r major minor patch <VERSION.txt | ||
git_hash=$(git rev-parse HEAD) | ||
if ! git diff-index --quiet HEAD; then | ||
git_hash="${git_hash}-dirty" | ||
fi | ||
base_hash=$(git rev-list --max-count=1 HEAD -- VERSION.txt) | ||
change_count=$(git rev-list --count HEAD "^$base_hash") | ||
short_hash=$(echo "$git_hash" | cut -c1-9) | ||
|
||
long_suffix="-t$short_hash" | ||
MINOR="$major.$minor" | ||
SHORT="$MINOR.$patch" | ||
LONG="${SHORT}$long_suffix" | ||
GIT_HASH="$git_hash" | ||
|
||
if [ "$1" = "shellvars" ]; then | ||
cat <<EOF | ||
VERSION_MINOR="$MINOR" | ||
VERSION_SHORT="$SHORT" | ||
VERSION_LONG="$LONG" | ||
VERSION_GIT_HASH="$GIT_HASH" | ||
EOF | ||
exit 0 | ||
fi | ||
|
||
export VERSION_MINOR="$MINOR" | ||
export VERSION_SHORT="$SHORT" | ||
export VERSION_LONG="$LONG" | ||
export VERSION_GIT_HASH="$GIT_HASH" | ||
|
||
goreleaser release --rm-dist "$@" |