Skip to content

Commit

Permalink
Build releases using Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
philwo committed Jun 4, 2019
1 parent 03601d2 commit a20cea2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
16 changes: 11 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@ gazelle(name = "gazelle")
sh_test(
name = "py_bazelisk_test",
srcs = ["bazelisk_test.sh"],
data = ["bazelisk.py", "releases_for_tests.json"],
args = ["PY"],
data = [
"bazelisk.py",
"releases_for_tests.json",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
args = ["PY"]
)

sh_test(
name = "go_bazelisk_test",
srcs = ["bazelisk_test.sh"],
data = [":bazelisk", "releases_for_tests.json"],
args = ["GO"],
data = [
"releases_for_tests.json",
":bazelisk",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
args = ["GO"]
)

go_library(
name = "go_default_library",
srcs = ["bazelisk.go"],
importpath = "github.com/philwo/bazelisk",
visibility = ["//visibility:private"],
deps = ["@com_github_hashicorp_go_version//:go_default_library"],
x_defs = {"BazeliskVersion": "{STABLE_VERSION}"},
deps = ["@com_github_hashicorp_go_version//:go_default_library"],
)

go_binary(
Expand Down
26 changes: 23 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@

set -euxo pipefail

GOOS=linux GOARCH=amd64 go build -o bin/bazelisk-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o bin/bazelisk-darwin-amd64
GOOS=windows GOARCH=amd64 go build -o bin/bazelisk-windows-amd64.exe
### Build release artifacts using Bazel.
go build
for platform in darwin linux windows; do
USE_BAZEL_VERSION=0.25.3 ./bazelisk build \
--stamp \
--workspace_status_command="$PWD/stamp.sh" \
--platforms=@io_bazel_rules_go//go/toolchain:${platform}_amd64 \
//:bazelisk
if [[ $platform == windows ]]; then
cp bazel-bin/${platform}_*/bazelisk.exe bin/bazelisk-${platform}-amd64.exe
else
cp bazel-bin/${platform}_*/bazelisk bin/bazelisk-${platform}-amd64
fi
done
rm -f bazelisk

### Build release artifacts using `go build`.
# GOOS=linux GOARCH=amd64 go build -o bin/bazelisk-linux-amd64
# GOOS=darwin GOARCH=amd64 go build -o bin/bazelisk-darwin-amd64
# GOOS=windows GOARCH=amd64 go build -o bin/bazelisk-windows-amd64.exe

### Print some information about the generated binaries.
file bin/*

0 comments on commit a20cea2

Please sign in to comment.