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

build: Move VERSION into version/version.go #2693

Merged
merged 1 commit into from Sep 11, 2020

Conversation

tsandall
Copy link
Member

This way the semantic version is always set. Tested by generating a fake release:

Cutting the release:

(dev)torin:~/src/opa$ make release-patch VERSION=0.24.0 > ~/test.patch
(dev)torin:~/src/opa$ patch -p1 < ~/test.patch
(Stripping trailing CRs from patch; use --binary to disable.)
patching file CHANGELOG.md
(Stripping trailing CRs from patch; use --binary to disable.)
patching file capabilities/v0.24.0.json
(Stripping trailing CRs from patch; use --binary to disable.)
patching file version/version.go
(dev)[*]torin:~/src/opa$ git add .
(dev)[*]torin:~/src/opa$ git commit -a -m 'wip: prepare release'
[dev 077c73b0] wip: prepare release
 3 files changed, 3236 insertions(+), 2 deletions(-)
 create mode 100644 capabilities/v0.24.0.json
(dev)torin:~/src/opa$ git tag v0.24.0

Checking the patches:

(dev)torin:~/src/opa$ head -n 10 CHANGELOG.md
# Change Log

All notable changes to this project will be documented in this file. This
project adheres to [Semantic Versioning](http://semver.org/).

## 0.24.0

### Fixes

- ast: Fix compiler to expand exprs in rule args ([#2649](https://github.com/open-policy-agent/opa/issues/2649))
----------------8<------------------
(dev)torin:~/src/opa$ head -n 10 version/version.go
// Copyright 2016 The OPA Authors.  All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.

// Package version contains version information that is set at build time.
package version

// Version is the canonical version of OPA.
var Version = "0.24.0"

Building and checking the version:

(dev)torin:~/src/opa$ make build
make[1]: Entering directory '/home/torin/src/opa/wasm'
make: '_obj/opa.wasm' is up to date.
make[1]: Leaving directory '/home/torin/src/opa/wasm'
cp wasm/_obj/opa.wasm internal/compiler/wasm/opa/opa.wasm
CGO_ENABLED=0 GO111MODULE=on GOFLAGS=-mod=vendor go generate
CGO_ENABLED=0 GO111MODULE=on GOFLAGS=-mod=vendor go build -o opa_linux_amd64 -ldflags " -X github.com/open-policy-agent/opa/version.Version=0.24.0 -X github.com/open-policy-agent/opa/version.Vcs=077c73b0 -X github.com/open-policy-agent/opa/version.Timestamp=2020-09-11T15:33:03Z -X github.com/open-policy-agent/opa/version.Hostname=bigbox.localdomain"
(dev)torin:~/src/opa$ ./opa_linux_amd64 version
Version: 0.24.0
Build Commit: 077c73b0
Build Timestamp: 2020-09-11T15:33:03Z
Build Hostname: bigbox.localdomain

Preparing for development of next release:

(dev)torin:~/src/opa$ make dev-patch VERSION=0.25.0 >~/test.patch
(dev)torin:~/src/opa$ patch -p1 < ~/test.patchpatch
(Stripping trailing CRs from patch; use --binary to disable.)
patching file CHANGELOG.md
(Stripping trailing CRs from patch; use --binary to disable.)
patching file version/version.go
(dev)[*]torin:~/src/opa$ git commit -a -m 'wip: prepare dev'
[dev 8f61e3e7] wip: prepare dev
 2 files changed, 3 insertions(+), 1 deletion(-)

Building development version and verifying the version number:

(dev)torin:~/src/opa$ make build
make[1]: Entering directory '/home/torin/src/opa/wasm'
make: '_obj/opa.wasm' is up to date.
make[1]: Leaving directory '/home/torin/src/opa/wasm'
cp wasm/_obj/opa.wasm internal/compiler/wasm/opa/opa.wasm
CGO_ENABLED=0 GO111MODULE=on GOFLAGS=-mod=vendor go generate
CGO_ENABLED=0 GO111MODULE=on GOFLAGS=-mod=vendor go build -o opa_linux_amd64 -ldflags " -X github.com/open-policy-agent/opa/version.Version=0.25.0-dev -X github.com/open-policy-agent/opa/version.Vcs=8f61e3e7 -X github.com/open-policy-agent/opa/version.Timestamp=2020-09-11T15:33:37Z -X github.com/open-policy-agent/opa/version.Hostname=bigbox.localdomain"
(dev)torin:~/src/opa$ ./opa_linux_amd64 version
Version: 0.25.0-dev
Build Commit: 8f61e3e7
Build Timestamp: 2020-09-11T15:33:37Z
Build Hostname: bigbox.localdomain

Verifying the CHANGELOG.md file is up-to-date for development:

(dev)torin:~/src/opa$ head -n 10 CHANGELOG.md
# Change Log

All notable changes to this project will be documented in this file. This
project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## 0.24.0

### Fixes

The decision logger unit tests had to be updated to always set the
version.Version value because they are sensitive to changes in the
payload sizes.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
@tsandall tsandall merged commit 7559ad0 into open-policy-agent:master Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants