From d5279ef41a138965e3678fe1c7dbb13a38cd16a4 Mon Sep 17 00:00:00 2001 From: sarahethompson Date: Wed, 11 Oct 2023 15:07:14 +0100 Subject: [PATCH 1/4] Onboarding consul-dataplane to VBA (version bump automation) as per - https://hashicorp.atlassian.net/wiki/spaces/RELENG/pages/2484306717/How+To+Onboard+Version+Bump+Automation --- .github/workflows/build.yml | 4 +--- .github/workflows/create-release-branch.yml | 10 ++++++++++ .release/ci.hcl | 9 +++++++++ cmd/consul-dataplane/main.go | 2 +- version/VERSION | 1 + {pkg/version => version}/fips_build.go | 0 {pkg/version => version}/non_fips_build.go | 0 {pkg/version => version}/version.go | 14 ++++++-------- 8 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/create-release-branch.yml create mode 100644 version/VERSION rename {pkg/version => version}/fips_build.go (100%) rename {pkg/version => version}/non_fips_build.go (100%) rename {pkg/version => version}/version.go (75%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 626301de..eebaa2b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,9 +38,7 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: get product version id: get-product-version - run: | - make version - echo "product-version=$(make version)" >> $GITHUB_OUTPUT + uses: hashicorp/actions-set-product-version@v1 generate-metadata-file: needs: get-product-version diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml new file mode 100644 index 00000000..cb6ed698 --- /dev/null +++ b/.github/workflows/create-release-branch.yml @@ -0,0 +1,10 @@ +name: create a release branch +on: [workflow_dispatch] +jobs: + create-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: hashicorp/actions-create-release-branch@v1 + with: + token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.release/ci.hcl b/.release/ci.hcl index bf2f9ffe..b364f8c9 100644 --- a/.release/ci.hcl +++ b/.release/ci.hcl @@ -124,3 +124,12 @@ event "promote-production-packaging" { on = "always" } } + +event "bump-version" { + depends = ["promote-production-packaging"] + action "bump-version" { + organization = "hashicorp" + repository = "crt-workflows-common" + workflow = "bump-version" + } +} diff --git a/cmd/consul-dataplane/main.go b/cmd/consul-dataplane/main.go index ca74a195..dbd9d32c 100644 --- a/cmd/consul-dataplane/main.go +++ b/cmd/consul-dataplane/main.go @@ -7,6 +7,7 @@ import ( "context" "flag" "fmt" + "github.com/hashicorp/consul-dataplane/version" "log" "os" "os/signal" @@ -14,7 +15,6 @@ import ( "syscall" "github.com/hashicorp/consul-dataplane/pkg/consuldp" - "github.com/hashicorp/consul-dataplane/pkg/version" ) var ( diff --git a/version/VERSION b/version/VERSION new file mode 100644 index 00000000..25b6557d --- /dev/null +++ b/version/VERSION @@ -0,0 +1 @@ +1.1.6-dev diff --git a/pkg/version/fips_build.go b/version/fips_build.go similarity index 100% rename from pkg/version/fips_build.go rename to version/fips_build.go diff --git a/pkg/version/non_fips_build.go b/version/non_fips_build.go similarity index 100% rename from pkg/version/non_fips_build.go rename to version/non_fips_build.go diff --git a/pkg/version/version.go b/version/version.go similarity index 75% rename from pkg/version/version.go rename to version/version.go index aad29c18..ad77e3c1 100644 --- a/pkg/version/version.go +++ b/version/version.go @@ -1,9 +1,7 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - package version import ( + _ "embed" "fmt" "strings" ) @@ -14,15 +12,15 @@ var ( GitCommit string // The main version number that is being run at the moment. - // // Version must conform to the format expected by github.com/hashicorp/go-version // for tests to work. - Version = "1.3.0" - - // A pre-release marker for the version. If this is "" (empty string) + // VersionPrerelease is a pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release // such as "dev" (in development), "beta", "rc1", etc. - VersionPrerelease = "dev" + // Version and VersionPrerelease info are now being embedded directly from the VERSION file. + //go:embed VERSION + fullVersion string + Version, VersionPrerelease, _ = strings.Cut(strings.TrimSpace(fullVersion), "-") ) // GetHumanVersion composes the parts of the version in a way that's suitable From 5199d6eee3c143d4c6e875da9a75e5dacc2ea6e4 Mon Sep 17 00:00:00 2001 From: sarahethompson Date: Wed, 11 Oct 2023 16:05:44 +0100 Subject: [PATCH 2/4] update version make target --- Makefile | 2 +- build-scripts/version.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a9b86d3d..e12b3c9f 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ PLATFORM = $(OS)/$(ARCH) DIST = dist/$(PLATFORM) BIN = $(DIST)/$(BIN_NAME) -VERSION = $(shell ./build-scripts/version.sh pkg/version/version.go) +VERSION = $(shell ./build-scripts/version.sh version/version.go) GIT_COMMIT?=$(shell git rev-parse --short HEAD) GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true) diff --git a/build-scripts/version.sh b/build-scripts/version.sh index 6affd155..93dc5b26 100755 --- a/build-scripts/version.sh +++ b/build-scripts/version.sh @@ -4,8 +4,8 @@ version_file=$1 -version=$(awk '$1 == "Version" && $2 == "=" { gsub(/"/, "", $3); print $3 }' < "${version_file}") -prerelease=$(awk '$1 == "VersionPrerelease" && $2 == "=" { gsub(/"/, "", $3); print $3 }' < "${version_file}") +version=$(awk -F- '{ print $1 }' < "${version_file}") +prerelease=$(awk -F- '{ print $2 }' < "${version_file}") if [ -n "$prerelease" ]; then echo "${version}-${prerelease}" From 44d9fd2cc5cc2a2ace4a514b5338b3290d91d315 Mon Sep 17 00:00:00 2001 From: sarahethompson Date: Wed, 11 Oct 2023 17:57:54 +0100 Subject: [PATCH 3/4] fixing file path/name --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e12b3c9f..a6540bc3 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ PLATFORM = $(OS)/$(ARCH) DIST = dist/$(PLATFORM) BIN = $(DIST)/$(BIN_NAME) -VERSION = $(shell ./build-scripts/version.sh version/version.go) +VERSION = $(shell ./build-scripts/version.sh version/VERSION) GIT_COMMIT?=$(shell git rev-parse --short HEAD) GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true) From 8e2fceacce35d229ea946d4fc9f0c31e365692ef Mon Sep 17 00:00:00 2001 From: sarahethompson Date: Fri, 13 Oct 2023 09:54:48 +0100 Subject: [PATCH 4/4] fix version --- version/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/VERSION b/version/VERSION index 25b6557d..b6bb93f7 100644 --- a/version/VERSION +++ b/version/VERSION @@ -1 +1 @@ -1.1.6-dev +1.3.0-dev