Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass correct compiler flags to go build for the release #1362

Merged
merged 10 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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