Skip to content

Commit

Permalink
chore: Modernize packaging scripts (#468)
Browse files Browse the repository at this point in the history
- Adds shebang directive for the default shell (used when the directive
  is missing).
- Uses `set -euxo pipefail` to enable important shell options.
- Ignore shellcheck warnings related to missing `compile.env` source
  files.
- Removes unnecessary GOPATH export.
- Removes `-mod=vendor` flag from `go build` command, as that flag is on
  by default in recent versions of Go.
  • Loading branch information
ctlong authored Oct 1, 2024
1 parent a017c5e commit a8c642c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 5 additions & 3 deletions packages/log-cache-cf-auth-proxy/packaging
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set -ex
#!/bin/bash

set -e -u -x -o pipefail

# shellcheck source=/dev/null
source /var/vcap/packages/golang-1.22-linux/bosh/compile.env
export GOPATH=/var/vcap

go build -mod=vendor -o ${BOSH_INSTALL_TARGET}/log-cache-cf-auth-proxy ./cmd/cf-auth-proxy
go build -o "${BOSH_INSTALL_TARGET}/log-cache-cf-auth-proxy" ./cmd/cf-auth-proxy
10 changes: 6 additions & 4 deletions packages/log-cache-gateway/packaging
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
set -ex
#!/bin/bash

set -e -u -x -o pipefail

# shellcheck source=/dev/null
source /var/vcap/packages/golang-1.22-linux/bosh/compile.env
export GOPATH=/var/vcap

VERSION=$(cat version)
go build -mod=vendor \
-o ${BOSH_INSTALL_TARGET}/log-cache-gateway \
go build \
-o "${BOSH_INSTALL_TARGET}/log-cache-gateway" \
-ldflags "-X main.buildVersion=${VERSION}" \
./cmd/gateway
8 changes: 5 additions & 3 deletions packages/log-cache-syslog-server/packaging
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set -ex
#!/bin/bash

set -e -u -x -o pipefail

# shellcheck source=/dev/null
source /var/vcap/packages/golang-1.22-linux/bosh/compile.env
export GOPATH=/var/vcap

go build -mod=vendor -o ${BOSH_INSTALL_TARGET}/log-cache-syslog-server ./cmd/syslog-server
go build -o "${BOSH_INSTALL_TARGET}/log-cache-syslog-server" ./cmd/syslog-server
8 changes: 5 additions & 3 deletions packages/log-cache/packaging
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set -ex
#!/bin/bash

set -e -u -x -o pipefail

# shellcheck source=/dev/null
source /var/vcap/packages/golang-1.22-linux/bosh/compile.env
export GOPATH=/var/vcap

go build -mod=vendor -o ${BOSH_INSTALL_TARGET}/log-cache ./cmd/log-cache
go build -o "${BOSH_INSTALL_TARGET}/log-cache" ./cmd/log-cache

0 comments on commit a8c642c

Please sign in to comment.