Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
release.sh: fix build versioning (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmizerany authored Oct 22, 2022
1 parent 20c0d8e commit 4c3e9c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 84 deletions.
20 changes: 7 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ builds:
goarch:
- amd64
main: ./cmd/tier
ldflags:
- -s -w
flags:
- -trimpath
binary: "tier"
ldflags:
- -X tier.run/version.Long={{.Env.VERSION_LONG}} -X tier.run/version.Short={{.Env.VERSION_SHORT}} -X tier.run/version.GitCommit={{.Env.VERSION_GIT_HASH}}
- id: darwin-arm64
goos:
- darwin
goarch:
- arm64
main: ./cmd/tier
ldflags:
- -s -w
flags:
- -trimpath
binary: "tier"
ldflags:
- -X tier.run/version.Long={{.Env.VERSION_LONG}} -X tier.run/version.Short={{.Env.VERSION_SHORT}} -X tier.run/version.GitCommit={{.Env.VERSION_GIT_HASH}}
- env:
- CGO_ENABLED=0
goos:
Expand All @@ -37,11 +33,9 @@ builds:
- amd64
- arm64
main: ./cmd/tier
ldflags:
- -s -w
flags:
- -trimpath
binary: "tier"
ldflags:
- -X tier.run/version.Long={{.Env.VERSION_LONG}} -X tier.run/version.Short={{.Env.VERSION_SHORT}} -X tier.run/version.GitCommit={{.Env.VERSION_GIT_HASH}}
# dockers:
# - image_templates:
# - "tier/tier:latest"
Expand Down Expand Up @@ -88,7 +82,7 @@ brews:
name: homebrew-tap
folder: Formula
test: |
system "#{bin}/tier --version"
system "#{bin}/tier version"
# install: |
# bin.install "tier"
# bash_completion.install "completions/tier.bash" => "tier"
Expand Down
71 changes: 0 additions & 71 deletions build_dist.sh

This file was deleted.

31 changes: 31 additions & 0 deletions release.sh
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 "$@"

0 comments on commit 4c3e9c7

Please sign in to comment.