Skip to content

Commit

Permalink
Merge pull request #148 from snyk/feat/adds-version-flag-for-ververt-…
Browse files Browse the repository at this point in the history
…version

feat: adds vervet's version info to cli
  • Loading branch information
jcsackett committed Feb 22, 2022
2 parents 232a756 + 90bf138 commit 3f01986
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.idea
.dccache
.vscode
/cmd/generate_version_init.go

**/server
config.json
3 changes: 3 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/urfave/cli/v2"
)

//go:generate ../scripts/genversion.bash

// VervetParams contains configuration parameters for the Vervet CLI application.
type VervetParams struct {
Stdin io.ReadCloser
Expand Down Expand Up @@ -67,6 +69,7 @@ func NewApp(vp VervetParams) *VervetApp {
Reader: vp.Stdin,
Writer: vp.Stdout,
ErrWriter: vp.Stderr,
Version: "develop", // Set in init created with go generate.
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Expand Down
2 changes: 2 additions & 0 deletions scripts/dist.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ rm -rf dist

mkdir -p ./dist/bin

go generate ./cmd/...

for GOOS in linux darwin; do
GOOS=$GOOS GOARCH=amd64 go build -a -o ./dist/bin/vervet-$GOOS-amd64 ./cmd/vervet
done
Expand Down
15 changes: 15 additions & 0 deletions scripts/genversion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eux
cd $(dirname $0)/..

[ -n "${VERSION}" ]

cat << EOF > cmd/generate_version_init.go
// THIS IS A GENERATED FILE. DO NOT EDIT.
package cmd
func init() {
Vervet.App.Version = "${VERSION}"
}
EOF
3 changes: 3 additions & 0 deletions scripts/release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if [ -z $(git config user.email) ]; then
git config user.email "vervet-ci@noreply.snyk.io"
git config user.name "Vervet CI"
fi

go generate ./cmd/...

git tag ${VERSION}
git push -q https://${GH_TOKEN}@github.com/snyk/vervet.git --tags

Expand Down

0 comments on commit 3f01986

Please sign in to comment.