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/Makefile b/Makefile index a9b86d3d..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 pkg/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) 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}" 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..b6bb93f7 --- /dev/null +++ b/version/VERSION @@ -0,0 +1 @@ +1.3.0-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