-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds goreleaser support to deterministically build and release binari…
…es (#3) * Adds goreleaser support to deterministically build and release binaries * Removes unused SNAPSHOT var * Removes mac SSH_AUTH_SOCK overrides * Adds comment to script
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
project_name: chronosphere | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- id: chronoctl | ||
main: ./src/cmd/chronoctl/main.go | ||
binary: chronoctl | ||
env: | ||
- CGO_ENABLED=0 | ||
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}" | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
archives: | ||
- name_template: >- | ||
{{ .Binary }}-{{ .Os }}{{- if eq .Os "darwin" }}-unsigned{{- end }}-{{ .Arch }} | ||
format: binary | ||
files: | ||
- none* | ||
blobs: | ||
- provider: gs | ||
bucket: chronosphere-release | ||
folder: "{{.Version}}" | ||
checksum: | ||
name_template: "{{ .ProjectName}}-checksums.txt" | ||
release: | ||
disable: true |
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,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
set -x | ||
[[ -z ${DEBUG:-} ]] || set -o xtrace | ||
|
||
# get the absolute path of the chronoctl-core directory no matter where the | ||
# script is called from. | ||
DIR="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. && pwd -P)" | ||
|
||
GITCONFIG_VOLUME=${GIT_CONFIG:-"${HOME}/.gitconfig"} | ||
GCLOUD_CONFIG_DIR="${CLOUDSDK_CONFIG:-${HOME}/.config/gcloud}" | ||
SSH_CONFIG_DIR_VOLUME="${HOME}/.ssh" | ||
SSH_AUTH_SOCK_ENV_VAR="/ssh-agent" | ||
SSH_AUTH_SOCK_VOLUME="${SSH_AUTH_SOCK}:/ssh-agent" | ||
|
||
if [[ "${BUILDKITE:-}" == "true" ]]; then | ||
GITCONFIG_VOLUME="/var/lib/buildkite-agent/.gitconfig" | ||
SSH_CONFIG_DIR_VOLUME="/var/lib/buildkite-agent/.ssh" | ||
fi | ||
|
||
|
||
DOCKER_OPTS=( | ||
-w "${GO_RELEASER_WORKING_DIR}" | ||
-e "GITHUB_TOKEN" # Set by CI | ||
-e "GO_BUILD_LDFLAGS" | ||
-e "CGO_ENABLED=0" | ||
-e "SSH_AUTH_SOCK=${SSH_AUTH_SOCK_ENV_VAR}" | ||
-v "${SSH_AUTH_SOCK_VOLUME}" | ||
-v "${SSH_CONFIG_DIR_VOLUME}:/root/.ssh" | ||
-v "${GITCONFIG_VOLUME}:/root/.gitconfig" | ||
-v "${DIR}:${GO_RELEASER_WORKING_DIR}" | ||
) | ||
|
||
if [[ "${BUILDKITE:-}" != "true" ]]; then | ||
DOCKER_OPTS+=(-v "${GCLOUD_CONFIG_DIR}:/root/.config/gcloud") | ||
fi | ||
|
||
# Run go mod vendor outside of container to utilize local cache | ||
go mod vendor | ||
|
||
# N.B. The GO_RELEASER_DOCKER_IMAGE is expected to be set by CI. | ||
docker run "${DOCKER_OPTS[@]}" "${GO_RELEASER_DOCKER_IMAGE}" release "$@" |