diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9aa8371c4..facc53c6f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -50,13 +50,12 @@ jobs: repository-cache: true # Bootstrap: the first time we release for windows, we don't have a windows version of Aspect CLI to build with # So use environment variables to defeat the .bazeliskrc file. - - run: bazel build //release:aspect_windows_amd64 - - run: cp $(bazel cquery //release:aspect_windows_amd64 --output=files) aspect_windows_amd64.exe - - name: smoke test - run: ./aspect_windows_amd64.exe --help + - run: bazel run --config=release //release:release.windows -- /tmp/aspect/release + # Verify that we built a functional executable + - run: ./$(bazel cquery //release:aspect-windows-x86_64.exe --output=files) --help - uses: actions/upload-artifact@v4 id: upload with: name: windows retention-days: 1 - path: aspect_windows_amd64.exe + path: /tmp/aspect/release diff --git a/release/BUILD.bazel b/release/BUILD.bazel index 8f7f2a7ed..a42976976 100644 --- a/release/BUILD.bazel +++ b/release/BUILD.bazel @@ -20,8 +20,9 @@ expand_template( ) platform_transition_filegroup( - name = "aspect_windows_amd64", + name = "aspect-windows-x86_64.exe", srcs = ["//cmd/aspect"], + tags = ["manual"], target_compatible_with = [ "@platforms//os:windows", "@platforms//cpu:x86_64", @@ -30,7 +31,14 @@ platform_transition_filegroup( ) bazelisk_artifacts( - name = "aspect_bazelisk_artifacts", + name = "windows_artifacts", + tags = ["manual"], + version_file = ":aspect_version", + windows_x86_64 = ":aspect-windows-x86_64.exe", +) + +bazelisk_artifacts( + name = "linux_and_darwin_artifacts", darwin_arm64 = ":aspect-macos-aarch64", darwin_x86_64 = ":aspect-macos-x86_64", linux_arm64 = ":aspect-linux-aarch64", @@ -44,7 +52,16 @@ release( tags = ["manual"], targets = [ ":aspect", - ":aspect_bazelisk_artifacts", + ":linux_and_darwin_artifacts", + ], +) + +release( + name = "release.windows", + tags = ["manual"], + targets = [ + ":aspect-windows-x86_64.exe", + ":windows_artifacts", ], ) diff --git a/release/bazelisk_artifacts.bzl b/release/bazelisk_artifacts.bzl index 4039e2b68..f3edb50a5 100644 --- a/release/bazelisk_artifacts.bzl +++ b/release/bazelisk_artifacts.bzl @@ -7,22 +7,18 @@ release for Bazelisk downloads. _ATTRS = { "darwin_arm64": attr.label( doc = "The artifact for the darwin-arm64 platform.", - mandatory = True, allow_single_file = True, ), "darwin_x86_64": attr.label( doc = "The artifact for the darwin-x86_64 platform.", - mandatory = True, allow_single_file = True, ), "linux_arm64": attr.label( doc = "The artifact for the linux-arm64 platform.", - mandatory = True, allow_single_file = True, ), "linux_x86_64": attr.label( doc = "The artifact for the linux-arm64 platform.", - mandatory = True, allow_single_file = True, ), "version_file": attr.label( @@ -30,6 +26,10 @@ _ATTRS = { mandatory = True, allow_single_file = True, ), + "windows_x86_64": attr.label( + doc = "The artifact for the windows-x86_64 platform.", + allow_single_file = True, + ), "_sha256sum": attr.label( executable = True, cfg = "exec", @@ -39,27 +39,31 @@ _ATTRS = { def _impl(ctx): outdir = ctx.actions.declare_directory(ctx.label.name) - - inputs = [ - ctx.file.version_file, - ctx.file.darwin_arm64, - ctx.file.darwin_x86_64, - ctx.file.linux_arm64, - ctx.file.linux_x86_64, - ] - + inputs = [ctx.file.version_file] args = ctx.actions.args() args.add(ctx.executable._sha256sum.path) args.add(outdir.path) args.add(ctx.file.version_file) - args.add(ctx.file.darwin_arm64) - args.add("darwin-arm64") - args.add(ctx.file.darwin_x86_64) - args.add("darwin-x86_64") - args.add(ctx.file.linux_arm64) - args.add("linux-arm64") - args.add(ctx.file.linux_x86_64) - args.add("linux-x86_64") + + if ctx.attr.windows_x86_64: + inputs.append(ctx.file.windows_x86_64) + args.add(ctx.file.windows_x86_64) + args.add("windows-x86_64.exe") + else: + inputs.extend([ + ctx.file.darwin_arm64, + ctx.file.darwin_x86_64, + ctx.file.linux_arm64, + ctx.file.linux_x86_64, + ]) + args.add(ctx.file.darwin_arm64) + args.add("darwin-arm64") + args.add(ctx.file.darwin_x86_64) + args.add("darwin-x86_64") + args.add(ctx.file.linux_arm64) + args.add("linux-arm64") + args.add(ctx.file.linux_x86_64) + args.add("linux-x86_64") ctx.actions.run_shell( outputs = [outdir], @@ -77,7 +81,7 @@ version="$(< "${version_file}")" mkdir -p "${output_dir}" while (("$#")); do - # Read args three at a time + # Read args in pairs artifact_path="$1" platform_suffix="$2" shift 2 diff --git a/release/release.bzl b/release/release.bzl index c70f90e39..a3d4f1343 100644 --- a/release/release.bzl +++ b/release/release.bzl @@ -73,7 +73,7 @@ def release(name, targets, **kwargs): native.genrule( name = name, srcs = targets, - outs = ["release.sh"], + outs = [name + ".sh"], executable = True, cmd = "./$(location //release:create_release.sh) {locations} > \"$@\"".format( locations = " ".join(["$(locations {})".format(target) for target in targets]),