Skip to content

Commit

Permalink
Pass correct compiler flags to go build for the release (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishustava authored Jul 20, 2022
1 parent 4edec7c commit 368d83f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ jobs:
working-directory: ${{ matrix.component }}
run: |
mkdir -p dist out
CGO_ENABLED=0 go build -o dist/${{ matrix.bin_name }} .
export GIT_COMMIT=$(git rev-parse --short HEAD)
export GIT_DIRTY=$(test -n "$(git status --porcelain)" && echo "+CHANGES")
export GIT_IMPORT=github.com/hashicorp/consul-k8s/${{ matrix.component }}/version
export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X ${GIT_IMPORT}.GitDescribe=${{ needs.get-product-version.outputs.product-version }}"
CGO_ENABLED=0 go build -o dist/${{ matrix.bin_name }} -ldflags "${GOLDFLAGS}" .
zip -r -j out/${{ matrix.pkg_name }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/
- name: Upload built binaries
Expand Down Expand Up @@ -150,7 +156,7 @@ jobs:
cd /work
rpm -ivh out/${{ env.RPM_PACKAGE }}
CONSUL_K8S_VERSION="$(consul-k8s version | awk '{print $2}')"
VERSION="${{ needs.get-product-version.outputs.product-version }}"
VERSION="v${{ needs.get-product-version.outputs.product-version }}"
if [ "${VERSION}" != "${CONSUL_K8S_VERSION}" ]; then
echo "Test FAILED, expected: ${VERSION}, got: ${CONSUL_K8S_VERSION}"
exit 1
Expand All @@ -175,7 +181,7 @@ jobs:
cd /work
apt install ./out/${{ env.DEB_PACKAGE }}
CONSUL_K8S_VERSION="$(consul-k8s version | awk '{print $2}')"
VERSION="${{ needs.get-product-version.outputs.product-version }}"
VERSION="v${{ needs.get-product-version.outputs.product-version }}"
if [ "${VERSION}" != "${CONSUL_K8S_VERSION}" ]; then
echo "Test FAILED, expected: ${VERSION}, got: ${CONSUL_K8S_VERSION}"
exit 1
Expand Down Expand Up @@ -206,7 +212,7 @@ jobs:
with:
smoke_test: |
TEST_VERSION="$(docker run "${IMAGE_NAME}" consul-k8s-control-plane version | awk '{print $2}')"
if [ "${TEST_VERSION}" != "${version}" ]; then
if [ "${TEST_VERSION}" != "v${version}" ]; then
echo "Test FAILED"
exit 1
fi
Expand Down Expand Up @@ -243,7 +249,7 @@ jobs:
with:
smoke_test: |
TEST_VERSION="$(docker run "${IMAGE_NAME}" consul-k8s-control-plane version | awk '{print $2}')"
if [ "${TEST_VERSION}" != "${version}" ]; then
if [ "${TEST_VERSION}" != "v${version}" ]; then
echo "Test FAILED"
exit 1
fi
Expand Down Expand Up @@ -275,7 +281,7 @@ jobs:
with:
smoke_test: |
TEST_VERSION="$(docker run "${IMAGE_NAME}" consul-k8s-control-plane version | awk '{print $2}')"
if [ "${TEST_VERSION}" != "${version}" ]; then
if [ "${TEST_VERSION}" != "v${version}" ]; then
echo "Test FAILED"
exit 1
fi
Expand Down
1 change: 1 addition & 0 deletions cli/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetHumanVersion() string {
if GitDescribe != "" {
version = GitDescribe
}
version = fmt.Sprintf("v%s", version)

release := VersionPrerelease
if GitDescribe == "" && release == "" {
Expand Down
1 change: 1 addition & 0 deletions control-plane/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetHumanVersion() string {
if GitDescribe != "" {
version = GitDescribe
}
version = fmt.Sprintf("v%s", version)

release := VersionPrerelease
if GitDescribe == "" && release == "" {
Expand Down

0 comments on commit 368d83f

Please sign in to comment.