From 3d077cc5f5e9406f5a74883d6106df13c42bae8d Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:00:50 -0600 Subject: [PATCH 01/10] Pass correct compiler flags to go build for the release --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8cf1e33d5b..7df64bb65b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,6 +109,13 @@ jobs: working-directory: ${{ matrix.component }} run: | mkdir -p dist out + + export GIT_COMMIT=$(git rev-parse --short HEAD) + export GIT_DIRTY=$(test -n "$(git status --porcelain)" && echo "+CHANGES") + export GIT_DESCRIBE=$(git describe --tags --always) + 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=${GIT_DESCRIBE}" + CGO_ENABLED=0 go build -o dist/${{ matrix.bin_name }} . zip -r -j out/${{ matrix.pkg_name }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/ From ad46292e26d9f7f9a09fe444d3283810fc60612c Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:01:41 -0600 Subject: [PATCH 02/10] run build on this branch --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7df64bb65b..8355ef3cf4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: - main # Push events to branches matching refs/heads/release/** - "release/**" + - ishustava/fix-release-build env: PKG_NAME: "consul-k8s" From ef92cafbe333ed94fb49e709b70c244bd8df2985 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:08:44 -0600 Subject: [PATCH 03/10] pass GOLDFLAGS to the build command --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8355ef3cf4..91547ee923 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -117,7 +117,7 @@ jobs: 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=${GIT_DESCRIBE}" - CGO_ENABLED=0 go build -o dist/${{ matrix.bin_name }} . + 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 From 8a1454733656269724f9e3045664e67197a1a078 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:23:30 -0600 Subject: [PATCH 04/10] pass correct version to GitDescribe --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91547ee923..f5d9f07bdc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,9 +113,8 @@ jobs: export GIT_COMMIT=$(git rev-parse --short HEAD) export GIT_DIRTY=$(test -n "$(git status --porcelain)" && echo "+CHANGES") - export GIT_DESCRIBE=$(git describe --tags --always) 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=${GIT_DESCRIBE}" + export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X ${GIT_IMPORT}.GitDescribe=v${{ 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/ From 46dfe430c5e7503d4a9a2e2c87d7635e9c95f155 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:28:22 -0600 Subject: [PATCH 05/10] add v to expected version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5d9f07bdc..9240d2ee43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -157,7 +157,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 From 2ba795fc65c5681e22430aee276cf2d366030efb Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:33:27 -0600 Subject: [PATCH 06/10] always set v in version --- .github/workflows/build.yml | 4 ++-- cli/version/version.go | 1 + control-plane/version/version.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9240d2ee43..f103396575 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,7 +114,7 @@ jobs: 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=v${{ needs.get-product-version.outputs.product-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/ @@ -157,7 +157,7 @@ jobs: cd /work rpm -ivh out/${{ env.RPM_PACKAGE }} CONSUL_K8S_VERSION="$(consul-k8s version | awk '{print $2}')" - VERSION="v${{ needs.get-product-version.outputs.product-version }}" + VERSION="${{ needs.get-product-version.outputs.product-version }}" if [ "${VERSION}" != "${CONSUL_K8S_VERSION}" ]; then echo "Test FAILED, expected: ${VERSION}, got: ${CONSUL_K8S_VERSION}" exit 1 diff --git a/cli/version/version.go b/cli/version/version.go index f2c9daac5b..186b748ad1 100644 --- a/cli/version/version.go +++ b/cli/version/version.go @@ -29,6 +29,7 @@ func GetHumanVersion() string { if GitDescribe != "" { version = GitDescribe } + version = fmt.Sprintf("v%s", version) release := VersionPrerelease if GitDescribe == "" && release == "" { diff --git a/control-plane/version/version.go b/control-plane/version/version.go index f2c9daac5b..186b748ad1 100644 --- a/control-plane/version/version.go +++ b/control-plane/version/version.go @@ -29,6 +29,7 @@ func GetHumanVersion() string { if GitDescribe != "" { version = GitDescribe } + version = fmt.Sprintf("v%s", version) release := VersionPrerelease if GitDescribe == "" && release == "" { From 21eafeecf701d2053cb5eeab1958e838ea57e8c1 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 13:47:05 -0600 Subject: [PATCH 07/10] put v in the expected version --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f103396575..11b4b25dd0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -157,7 +157,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 @@ -182,7 +182,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 From 0d6abc9d1b8dfe8d94b2eba1aee3a34acf999b03 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 14:00:44 -0600 Subject: [PATCH 08/10] add more vs --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11b4b25dd0..ed5daca629 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -205,7 +205,7 @@ jobs: arch: ["arm", "arm64", "386", "amd64"] env: repo: ${{ github.event.repository.name }} - version: ${{ needs.get-product-version.outputs.product-version }} + version: v${{ needs.get-product-version.outputs.product-version }} steps: - uses: actions/checkout@v2 - name: Docker Build (Action) @@ -240,7 +240,7 @@ jobs: arch: ["amd64"] env: repo: ${{ github.event.repository.name }} - version: ${{ needs.get-product-version.outputs.product-version }} + version: v${{ needs.get-product-version.outputs.product-version }} steps: - uses: actions/checkout@v2 - name: Copy LICENSE.md @@ -272,7 +272,7 @@ jobs: arch: [ "amd64" ] env: repo: ${{ github.event.repository.name }} - version: ${{ needs.get-product-version.outputs.product-version }} + version: v${{ needs.get-product-version.outputs.product-version }} steps: - uses: actions/checkout@v2 - name: Copy LICENSE.md From f08ef49e7097d4e13532bf01af76f76bef624434 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 14:17:17 -0600 Subject: [PATCH 09/10] add vs in correct places --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed5daca629..f82f8631b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -205,7 +205,7 @@ jobs: arch: ["arm", "arm64", "386", "amd64"] env: repo: ${{ github.event.repository.name }} - version: v${{ needs.get-product-version.outputs.product-version }} + version: ${{ needs.get-product-version.outputs.product-version }} steps: - uses: actions/checkout@v2 - name: Docker Build (Action) @@ -213,7 +213,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 @@ -240,7 +240,7 @@ jobs: arch: ["amd64"] env: repo: ${{ github.event.repository.name }} - version: v${{ needs.get-product-version.outputs.product-version }} + version: ${{ needs.get-product-version.outputs.product-version }} steps: - uses: actions/checkout@v2 - name: Copy LICENSE.md @@ -250,7 +250,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 @@ -272,7 +272,7 @@ jobs: arch: [ "amd64" ] env: repo: ${{ github.event.repository.name }} - version: v${{ needs.get-product-version.outputs.product-version }} + version: ${{ needs.get-product-version.outputs.product-version }} steps: - uses: actions/checkout@v2 - name: Copy LICENSE.md @@ -282,7 +282,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 From 0a68008362bb80f820c47967219b14ecb4c95d74 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Wed, 20 Jul 2022 14:37:07 -0600 Subject: [PATCH 10/10] remove this branch --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f82f8631b6..3b691fb307 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ on: - main # Push events to branches matching refs/heads/release/** - "release/**" - - ishustava/fix-release-build env: PKG_NAME: "consul-k8s"