Skip to content

Commit

Permalink
fix(ci): use FullCommit and align version.sh logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Aug 6, 2024
1 parent d94047a commit 135b928
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 3 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ env:
- CC_windows_amd64=x86_64-w64-mingw32-gcc
- CXX_windows_amd64=x86_64-w64-mingw32-g++
- VERSION={{ .Version }}
- COMMIT={{ .Commit }}
- BUILDTIME={{ .Date }}
# - CC_windows_arm64= NOT_CREATING_WINDOWS_ARM64_BINARIES
# - CXX_windows_arm64= NOT_CREATING_WINDOWS_ARM64_BINARIES
Expand Down Expand Up @@ -54,10 +53,10 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.ServerName=zetacored
- -X github.com/cosmos/cosmos-sdk/version.ClientName=zetaclientd
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Env.COMMIT }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .FullCommit }}
- -X github.com/zeta-chain/zetacore/pkg/constant.Name=zetacored
- -X github.com/zeta-chain/zetacore/pkg/constant.Version={{ .Version }}
- -X github.com/zeta-chain/zetacore/pkg/constant.CommitHash={{ .Env.COMMIT }}
- -X github.com/zeta-chain/zetacore/pkg/constant.CommitHash={{ .FullCommit }}
- -X github.com/zeta-chain/zetacore/pkg/constant.BuildTime={{ .Env.BUILDTIME }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

Expand Down Expand Up @@ -100,7 +99,7 @@ release:
# Available only for GitHub and Gitea.
draft: false

target_commitish: "{{ .Commit }}"
target_commitish: "{{ .FullCommit }}"

# If set, will create a release discussion in the category specified.
#
Expand Down
8 changes: 5 additions & 3 deletions version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
# --exact-match will ensure the tag is only returned if our commit is a tag
version=$(git describe --exact-match --tags 2>/dev/null)
if [[ $? -eq 0 ]]; then
echo $version
# do not return v prefix on the version
# to match the goreleaser logic
echo ${version#v}
exit
fi

# use current timestamp for dirty builds
if ! git diff --no-ext-diff --quiet --exit-code ; then
current_timestamp=$(date +"%s")
echo "v0.0.${current_timestamp}-dirty"
echo "0.0.${current_timestamp}-dirty"
exit
fi

# otherwise assume we are on a develop build and use commit timestamp for version
commit_timestamp=$(git show --no-patch --format=%at)

echo "v0.0.${commit_timestamp}-develop"
echo "0.0.${commit_timestamp}-develop"

0 comments on commit 135b928

Please sign in to comment.