Skip to content

Commit

Permalink
Make version a var and add arr_build.sh
Browse files Browse the repository at this point in the history
By change Version from and const to a var we are able to use
ldflags to set the version dynamically.

In the arr_build.sh file for example, we can set it with:
-ldflags="-X go.mozilla.org/sops/v3/version.Version=$VERSION"

arr_build.sh will buld the sops binary in the repo root
and will print the instructions for releasing it to gcs.
  • Loading branch information
Karl Schriek committed Mar 8, 2022
1 parent 68e2a82 commit 96daa0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions arr_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e
VERSION=$(git describe)
VERSION="${VERSION:1}" # change example v3.7.1 to 3.7.1
go build -o sops -ldflags="-X go.mozilla.org/sops/v3/version.Version=$VERSION" ./cmd/sops

echo "Successfully built with version: $(./sops --version)"

BUCKET=arrikto
OBJECT=sops/sops-${VERSION}
GSURL=gs://${BUCKET}/${OBJECT}
URL=https://storage.googleapis.com/${BUCKET}/${OBJECT}

echo To upload to GCS run:
echo " gsutil cp ./sops ${GSURL}"

echo To make it public run:
echo " gsutil acl ch -u AllUsers:R ${GSURL}"

echo To verify that it is publicly accessible run:
echo " curl -I ${URL}"

2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// Version represents the value of the current semantic version
const Version = "3.7.1"
var Version = "3.7.1"

// PrintVersion handles the version command for sops
func PrintVersion(c *cli.Context) {
Expand Down

0 comments on commit 96daa0b

Please sign in to comment.