|
1 | | -#!/bin/bash |
2 | | -# |
3 | | -# This script builds the application from source for only this platform. |
4 | | -set -e |
5 | | - |
6 | | -# Get the parent directory of where this script is. |
7 | | -SOURCE="${BASH_SOURCE[0]}" |
8 | | -while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done |
9 | | -DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" |
10 | | - |
11 | | -# Change into that directory |
12 | | -cd $DIR |
13 | | - |
14 | | -# Get the git commit |
15 | | -GIT_COMMIT=$(git rev-parse HEAD) |
16 | | -GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true) |
17 | | - |
18 | | -# If we're building on Windows, specify an extension |
19 | | -EXTENSION="" |
20 | | -if [ "$(go env GOOS)" = "windows" ]; then |
21 | | - EXTENSION=".exe" |
22 | | -fi |
23 | | - |
24 | | -GOPATHSINGLE=${GOPATH%%:*} |
25 | | -if [ "$(go env GOOS)" = "windows" ]; then |
26 | | - GOPATHSINGLE=${GOPATH%%;*} |
27 | | -fi |
28 | | - |
29 | | -# Install dependencies |
30 | | -echo "--> Getting dependencies..." |
31 | | -go get ./... |
32 | | - |
33 | | -# Build! |
34 | | -echo "--> Building..." |
35 | | -gox \ |
36 | | - -os="$(go env GOOS)" \ |
37 | | - -arch="$(go env GOARCH)" \ |
38 | | - -ldflags "-X main.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \ |
39 | | - -output "bin/terraform-{{.Dir}}" \ |
40 | | - ./... |
41 | | -mv bin/terraform-terraform${EXTENSION} bin/terraform${EXTENSION} |
42 | | -cp bin/terraform* ${GOPATHSINGLE}/bin |
43 | | - |
44 | | -# Done! |
45 | | -echo |
46 | | -echo "--> Results:" |
47 | | -ls -hl bin/ |
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# This script builds the application from source for only this platform. |
| 4 | +set -e |
| 5 | + |
| 6 | +# Get the parent directory of where this script is. |
| 7 | +SOURCE="${BASH_SOURCE[0]}" |
| 8 | +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done |
| 9 | +DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" |
| 10 | + |
| 11 | +# Change into that directory |
| 12 | +cd $DIR |
| 13 | + |
| 14 | +# Get the git commit |
| 15 | +GIT_COMMIT=$(git rev-parse HEAD) |
| 16 | +GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true) |
| 17 | + |
| 18 | +# If we're building on Windows, specify an extension |
| 19 | +EXTENSION="" |
| 20 | +if [ "$(go env GOOS)" = "windows" ]; then |
| 21 | + EXTENSION=".exe" |
| 22 | +fi |
| 23 | + |
| 24 | +GOPATHSINGLE=${GOPATH%%:*} |
| 25 | +if [ "$(go env GOOS)" = "windows" ]; then |
| 26 | + GOPATHSINGLE=${GOPATH%%;*} |
| 27 | +fi |
| 28 | + |
| 29 | +# Install dependencies |
| 30 | +echo "--> Getting dependencies..." |
| 31 | +go get ./... |
| 32 | + |
| 33 | +# Build! |
| 34 | +echo "--> Building..." |
| 35 | +gox \ |
| 36 | + -os="$(go env GOOS)" \ |
| 37 | + -arch="$(go env GOARCH)" \ |
| 38 | + -ldflags "-X main.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \ |
| 39 | + -output "bin/terraform-{{.Dir}}" \ |
| 40 | + ./... |
| 41 | +mv bin/terraform-terraform${EXTENSION} bin/terraform${EXTENSION} |
| 42 | +cp bin/terraform* ${GOPATHSINGLE}/bin |
| 43 | + |
| 44 | +# Done! |
| 45 | +echo |
| 46 | +echo "--> Results:" |
| 47 | +ls -hl bin/ |
0 commit comments