-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fix-visibility release artifacts #67
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,18 @@ jobs: | |
run: git status --porcelain | ||
- name: bazel test //... | ||
env: | ||
# Bazelisk will download bazel to here | ||
# Bazelisk will download bazel to here. | ||
XDG_CACHE_HOME: ~/.cache/bazel-repo | ||
run: | ||
run: | | ||
# Test the repository. | ||
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test | ||
--config=release //... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe we don't want to test with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could argue that we don't need a test at all since we will only tag commits on |
||
# Copy the release artifacts to /tmp/aspect/release. | ||
rm -rf /tmp/aspect/release | ||
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run | ||
--config=release //release -- /tmp/aspect/release | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
prerelease: true | ||
files: | | ||
bazel-out/*-opt-*/bin/cmd/aspect/aspect-linux_amd64 | ||
bazel-out/*-opt-*/bin/cmd/aspect/aspect-linux_arm64 | ||
bazel-out/*-opt-*/bin/cmd/aspect/aspect-darwin_amd64 | ||
bazel-out/*-opt-*/bin/cmd/aspect/aspect-darwin_arm64 | ||
bazel-out/*-opt-*/bin/cmd/aspect/aspect-windows_amd64.exe | ||
files: /tmp/aspect/release/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
load(":release.bzl", "multi_platform_binaries", "release") | ||
|
||
multi_platform_binaries( | ||
name = "aspect", | ||
embed = ["//cmd/aspect:aspect_lib"], | ||
) | ||
|
||
multi_platform_binaries( | ||
name = "fix-visibility", | ||
embed = ["//plugins/fix-visibility:fix-visibility_lib"], | ||
prefix = "plugin-", | ||
) | ||
|
||
release( | ||
name = "release", | ||
targets = [ | ||
":aspect", | ||
":fix-visibility", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
echo '#!/bin/bash' | ||
echo 'set -o errexit -o nounset -o pipefail' | ||
# shellcheck disable=SC2016 | ||
echo 'dst=$1' | ||
# shellcheck disable=SC2016 | ||
echo 'mkdir -p "${dst}"' | ||
|
||
for artifact in "$@"; do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh, don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the files are passed from |
||
echo "echo \"Copying ${artifact} to \${dst}\"" | ||
echo "cp \"${artifact}\" \"\${dst}\"" | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""This module provides the macros for performing a release. | ||
""" | ||
|
||
load("@io_bazel_rules_go//go:def.bzl", "go_binary") | ||
|
||
PLATFORMS = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rad |
||
struct(os = "darwin", arch = "amd64", ext = "", gc_linkopts = ["-s", "-w"]), | ||
struct(os = "darwin", arch = "arm64", ext = "", gc_linkopts = ["-s", "-w"]), | ||
struct(os = "linux", arch = "amd64", ext = "", gc_linkopts = ["-s", "-w"]), | ||
struct(os = "linux", arch = "arm64", ext = "", gc_linkopts = ["-s", "-w"]), | ||
struct(os = "windows", arch = "amd64", ext = ".exe", gc_linkopts = []), | ||
] | ||
|
||
def multi_platform_binaries(name, embed, prefix = ""): | ||
"""The multi_platform_binaries macro creates a go_binary for each platform. | ||
|
||
Args: | ||
name: the name of the filegroup containing all go_binary targets produced | ||
by this macro. | ||
embed: the list of targets passed to each go_binary target in this | ||
macro. | ||
prefix: an optional prefix added to the output Go binary file name. | ||
""" | ||
targets = [] | ||
for platform in PLATFORMS: | ||
target_name = "{}-{}-{}".format(name, platform.os, platform.arch) | ||
go_binary( | ||
name = target_name, | ||
out = "{}{}-{}_{}{}".format(prefix, name, platform.os, platform.arch, platform.ext), | ||
embed = embed, | ||
gc_linkopts = platform.gc_linkopts, | ||
goarch = platform.arch, | ||
goos = platform.os, | ||
pure = "on", | ||
visibility = ["//visibility:public"], | ||
) | ||
targets.append(Label("//{}:{}".format(native.package_name(), target_name))) | ||
|
||
native.filegroup( | ||
name = name, | ||
srcs = targets, | ||
) | ||
|
||
def release(name, targets): | ||
"""The release macro creates the artifact copier script. | ||
|
||
It's an executable script that copies all artifacts produced by the given | ||
targets into the provided destination. See .github/workflows/release.yml. | ||
|
||
Args: | ||
name: the name of the genrule. | ||
targets: a list of filegroups passed to the artifact copier. | ||
""" | ||
native.genrule( | ||
name = name, | ||
srcs = targets, | ||
outs = ["release.sh"], | ||
executable = True, | ||
cmd = "./$(location //release:create_release.sh) {locations} > \"$@\"".format( | ||
locations = " ".join(["$(locations {})".format(target) for target in targets]), | ||
), | ||
tools = ["//release:create_release.sh"], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we don't actually have to download bazelisk!
bazel-contrib/rules_bazel_integration_test#1 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will defer this to another PR.