-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from fission/include-git-version
Include git info in versioning
- Loading branch information
Showing
18 changed files
with
444 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
rm -f ./fission-workflows-bundle ./wfcli | ||
GOOS=linux GOARCH=386 go build github.com/fission/fission-workflows/cmd/fission-workflows-bundle/ | ||
GOOS=linux GOARCH=386 go build github.com/fission/fission-workflows/cmd/wfcli/ | ||
$(dirname $0)/build.sh --os linux --arch amd64 \ | ||
--output-bundle "fission-workflows-bundle" \ | ||
--output-cli "wfcli" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -o wfcli-osx github.com/fission/fission-workflows/cmd/wfcli/ | ||
GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -o fission-workflows-bundle-osx github.com/fission/fission-workflows/cmd/fission-workflows-bundle/ | ||
$(dirname $0)/build.sh --os darwin --arch 386 \ | ||
--output-bundle "fission-workflows-bundle-osx" \ | ||
--output-cli "wfcli-osx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o fission-workflows-bundle-windows.exe github.com/fission/fission-workflows/cmd/fission-workflows-bundle/ | ||
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o wfcli-windows.exe github.com/fission/fission-workflows/cmd/wfcli/ | ||
$(dirname $0)/build.sh --os windows --arch 386 \ | ||
--output-bundle "fission-workflows-bundle-windows" \ | ||
--output-cli "wfcli-windows" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
# Constants | ||
versionPath="github.com/fission/fission-workflows/pkg/version" | ||
|
||
# Handle arguments | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-d| --date) | ||
date=$2 | ||
shift | ||
;; | ||
-c| --commit) | ||
gitcommit=$2 | ||
shift | ||
;; | ||
-v| --version) | ||
version=$2 | ||
shift | ||
;; | ||
--os) | ||
goos=$2 | ||
shift | ||
;; | ||
--arch) | ||
goarch=$2 | ||
shift | ||
;; | ||
--output-bundle) | ||
output_bundle=$2 | ||
shift | ||
;; | ||
--output-cli) | ||
output_cli=$2 | ||
shift | ||
;; | ||
-h| --help) | ||
echo "usage: build.sh [-c commit] [-d date] [-v version] [--arch arch] [--os os] [--output-bundle name] [--output-cli name]" | ||
exit 0; | ||
esac | ||
shift | ||
done | ||
|
||
# Set defaults | ||
if [ -z ${version:-} ]; then | ||
version=$(git rev-parse HEAD) | ||
fi | ||
|
||
if [ -z ${date:-} ] ; then | ||
date=$(date -R) | ||
fi | ||
|
||
if [ -z ${gitcommit:-} ] ; then | ||
gitcommit=$(git rev-parse HEAD) | ||
fi | ||
goos=${goos:-linux} | ||
goarch=${goarch:-amd64} | ||
output_cli=${output_cli:-wfcli} | ||
output_bundle=${output_bundle:-fission-workflows-bundle} | ||
|
||
echo "-------- Build config --------" | ||
echo "version: ${version}" | ||
echo "date: ${date}" | ||
echo "commit: ${gitcommit}" | ||
echo "goarch: ${goarch}" | ||
echo "goos: ${goos}" | ||
echo "output-cli: ${output_cli}" | ||
echo "output-bundle: ${output_bundle}" | ||
echo "------------------------------" | ||
|
||
# Build client | ||
CGO_ENABLED=0 GOOS=${goos} GOARCH=${goarch} go build \ | ||
-gcflags=-trimpath=${GOPATH} -asmflags=-trimpath=${GOPATH}\ | ||
-ldflags '-X "${versionPath}.BuildDate=${date}"'\ | ||
-o ${output_cli}\ | ||
github.com/fission/fission-workflows/cmd/wfcli/ | ||
echo "$(pwd)/${output_cli}" | ||
|
||
# Build bundle | ||
CGO_ENABLED=0 GOOS=${goos} GOARCH=${goarch} go build\ | ||
-gcflags=-trimpath=${GOPATH} -asmflags=-trimpath=${GOPATH}\ | ||
-ldflags '-X "${versionPath}.BuildDate=${date}"'\ | ||
-o ${output_bundle}\ | ||
github.com/fission/fission-workflows/cmd/fission-workflows-bundle/ | ||
echo "$(pwd)/${output_bundle}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ func main() { | |
app := cli.NewApp() | ||
app.Author = "Erwin van Eyk" | ||
app.Email = "[email protected]" | ||
app.Version = version.VERSION | ||
app.Version = version.Version | ||
app.EnableBashCompletion = true | ||
app.Usage = "Fission Workflows CLI" | ||
app.Description = "CLI for Fission Workflows" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
gopath=`find pkg -type f -name "*.go" | xargs -n 1 dirname | sort --unique` | ||
while read -r path; do | ||
(cd ${path} && go generate -x) | ||
done <<< "$gopath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
protopaths=`find pkg -type f -name "*.proto"` | ||
while read -r path; do | ||
echo "Generating golang implementations for proto-file: $path" | ||
echo "$path" | ||
protoc -I . \ | ||
-I /usr/local/include \ | ||
-I ./pkg/ \ | ||
-I $GOPATH/src \ | ||
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ | ||
-I ${GOPATH}/src \ | ||
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ | ||
--proto_path=.\ | ||
--go_out=plugins=grpc:.\ | ||
--grpc-gateway_out=logtostderr=true:. \ | ||
${path} | ||
done <<< "$protopaths" | ||
|
||
echo "Generating golang HTTP gateway for proto-file: pkg/apiserver/apiserver.proto" | ||
protoc -I . \ | ||
-I/usr/local/include \ | ||
-I ./pkg/ \ | ||
-I $GOPATH/src \ | ||
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ | ||
--grpc-gateway_out=logtostderr=true:. \ | ||
--go_out=plugins=grpc:. \ | ||
pkg/apiserver/apiserver.proto | ||
|
||
done <<< "$protopaths" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Handle arguments | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-d| --date) | ||
GIT_DATE=$2 | ||
shift | ||
;; | ||
-c| --commit) | ||
GIT_COMMIT=$2 | ||
shift | ||
;; | ||
-v| --version) | ||
VERSION=$2 | ||
shift | ||
;; | ||
-o| --output) | ||
OUTPUT=$2 | ||
shift | ||
;; | ||
-h| --help) | ||
echo "usage: codegen-version.sh [-c commit] [-d RFC3339] [-v version]" | ||
exit 0; | ||
esac | ||
shift | ||
done | ||
|
||
if [ -z ${VERSION:-} ]; then | ||
VERSION=$(git rev-parse HEAD) | ||
fi | ||
|
||
if [ -z ${GIT_DATE:-} ] ; then | ||
# or use `date -R` | ||
GIT_DATE=$(git show -s --format="%cD" HEAD) | ||
fi | ||
|
||
if [ -z ${GIT_COMMIT:-} ] ; then | ||
GIT_COMMIT=$(git rev-parse HEAD) | ||
fi | ||
|
||
read -r -d '' VERSION << EOM | ||
// Code generated by hack/codegen-version.sh. DO NOT EDIT. | ||
package version | ||
import "time" | ||
const ( | ||
dateFormat string = time.RFC1123Z | ||
// Git commit (e.g. 1b4716ab84903b2e477135a3dc5afdb07f685cb7) | ||
GitCommit string = "${GIT_COMMIT}" | ||
// Version contains a (potentially) human-readable version | ||
// For example 1.1.0 or 1b4716ab84903b2e477135a3dc5afdb07f685cb7 | ||
Version string = "${VERSION}" | ||
// gitDate is a date in RFC1123Z format | ||
gitDate string = "${GIT_DATE}" | ||
) | ||
var ( | ||
GitDate time.Time | ||
) | ||
func init() { | ||
d, err := time.Parse(dateFormat, gitDate) | ||
if err != nil { | ||
panic(err) | ||
} | ||
GitDate = d | ||
} | ||
EOM | ||
|
||
if [ -z ${OUTPUT:-} ] ; then | ||
echo "${VERSION}" | ||
else | ||
echo "${VERSION}" > ${OUTPUT} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.