Skip to content

Commit 7dae2cf

Browse files
alexeaglegregmagolan
authored andcommitted
chore: add windows release
1 parent e12b77d commit 7dae2cf

File tree

9 files changed

+232
-128
lines changed

9 files changed

+232
-128
lines changed

.bazelrc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ import %workspace%/.aspect/bazelrc/javascript.bazelrc
77
import %workspace%/.aspect/bazelrc/performance.bazelrc
88

99
### YOUR PROJECT SPECIFIC OPTIONS GO HERE ###
10+
common --enable_platform_specific_config
1011

11-
# Allow our init template folders to contain BUILD.bazel without it being a subpackage
12-
# To update, run:
13-
# find pkg/aspect/init/template -type d | paste -d, -s - | awk '{ print "common --deleted_packages="$1 }'
14-
common --deleted_packages=pkg/aspect/init/template,pkg/aspect/init/template/tools,pkg/aspect/init/template/tools/format
15-
16-
common --workspace_status_command "${PWD}/workspace_status.sh"
17-
18-
common:release -c opt --stamp
12+
common:release -c opt --stamp --workspace_status_command="node tools/workspace_status.js"
1913

2014
# bzlmod causes issues with LLVM toolchain
2115
common --noenable_bzlmod
@@ -24,8 +18,10 @@ common --noenable_bzlmod
2418
common --noincompatible_disallow_empty_glob
2519

2620
# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains.
27-
common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
28-
common --incompatible_enable_cc_toolchain_resolution --incompatible_enable_proto_toolchain_resolution
21+
common:linux --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
22+
common --incompatible_enable_proto_toolchain_resolution
23+
24+
build:windows --sandbox_add_mount_pair=C:\Temp
2925

3026
# Tell Bazel to pass the right flags for llvm-ar, not libtool, only needed on linux.
3127
# See https://github.com/bazelbuild/bazel/blob/5c75d0acec21459bbb13520817e3806e1507e907/tools/cpp/unix_cc_toolchain_config.bzl#L1000-L1024

.github/workflows/build.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: build
2+
on:
3+
push:
4+
branches: ['main']
5+
pull_request:
6+
workflow_call:
7+
outputs:
8+
windows:
9+
description: 'Windows binaries'
10+
value: ${{jobs.build_windows.outputs.artifact}}
11+
linux:
12+
description: 'Linux and MacOS binaries'
13+
value: ${{jobs.build.outputs.artifact}}
14+
jobs:
15+
build:
16+
name: darwin and linux
17+
runs-on: ubuntu-latest
18+
outputs:
19+
artifact: ${{steps.upload.outputs.artifact-url}}
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0 # Needed to see tags
24+
- run: |
25+
bazel run --config=release //release -- /tmp/aspect/release
26+
- uses: actions/upload-artifact@v4
27+
id: upload
28+
with:
29+
name: linux
30+
retention-days: 1
31+
path: /tmp/aspect/release
32+
# Cross-compiling to Windows is too hard. Just build on a windows runner instead.
33+
build_windows:
34+
name: windows
35+
runs-on: windows-2022
36+
outputs:
37+
artifact: ${{steps.upload.outputs.artifact-url}}
38+
env:
39+
USE_BAZEL_VERSION: 7.2.1
40+
BAZELISK_BASE_URL: https://github.com/bazelbuild/bazel/releases/download
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0 # Needed to see tags
45+
- uses: bazel-contrib/[email protected]
46+
with:
47+
# Avoid downloading Bazel every time.
48+
bazelisk-cache: true
49+
# Store build cache per workflow.
50+
disk-cache: ${{ github.workflow }}
51+
# Share repository cache between workflows.
52+
repository-cache: true
53+
- run: bazel build --config=release //release:release.windows
54+
- run: bazel-bin/release/release.windows.sh "C:\Temp\release"
55+
shell: bash
56+
# Verify that we built a functional executable
57+
- name: smoke test
58+
run: |
59+
cp $(bazel cquery --config=release --output=files //release:aspect-windows-x86_64.exe) aspect.exe
60+
./aspect.exe --help
61+
- uses: actions/upload-artifact@v4
62+
id: upload
63+
with:
64+
name: windows
65+
retention-days: 1
66+
path: C:\Temp\release

.github/workflows/release.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
name: Release
22
on:
3+
# Allow manual testing by invoking this workflow from the GH web UI
4+
workflow_dispatch:
35
push:
46
tags:
57
- '202*.*.*'
68
jobs:
7-
build:
9+
build_all:
10+
uses: ./.github/workflows/build.yaml
11+
release:
812
runs-on: ubuntu-latest
13+
needs: build_all
914
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v4
15+
- uses: actions/checkout@v4
16+
- uses: actions/download-artifact@v4
1217
with:
13-
fetch-depth: 0
14-
- name: Build release artifacts
15-
run: |
16-
if [ -n "$(git status --porcelain)" ]; then
17-
>&2 echo "ERROR: the git state is not clean, aborting build..."
18-
exit 1
19-
fi
20-
rm -rf /tmp/aspect/release
21-
bazel run --config=release //release -- /tmp/aspect/release
22-
if /tmp/aspect/release/aspect-linux_amd64 version | grep '(with local changes)'; then
23-
>&2 echo "ERROR: the release contained changes in the git state and the release will not be produced"
24-
exit 1
25-
fi
18+
merge-multiple: true
19+
- run: shasum -a 256 aspect* > SHA256.txt
2620
- name: Prepare workspace snippet
2721
run: .github/workflows/install_snippet.sh > release_notes.txt
2822
- name: Create GitHub draft release and upload artifacts
29-
uses: softprops/action-gh-release@v1
23+
uses: softprops/action-gh-release@v2
3024
with:
3125
# Use GH feature to populate the changelog automatically
3226
generate_release_notes: true
3327
body_path: release_notes.txt
34-
files: /tmp/aspect/release/*
28+
files: |
29+
aspect*
30+
SHA256.txt

WORKSPACE

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ workspace(name = "build_aspect_cli")
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44

5+
HERMETIC_CC_TOOLCHAIN_VERSION = "v3.1.1"
6+
7+
http_archive(
8+
name = "hermetic_cc_toolchain",
9+
sha256 = "907745bf91555f77e8234c0b953371e6cac5ba715d1cf12ff641496dd1bce9d1",
10+
urls = [
11+
"https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
12+
"https://github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
13+
],
14+
)
15+
16+
load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains")
17+
18+
zig_toolchains()
19+
20+
register_toolchains(
21+
"@zig_sdk//toolchain:windows_amd64",
22+
"@zig_sdk//toolchain:windows_arm64",
23+
)
24+
525
http_archive(
626
name = "bazel_features",
727
sha256 = "2cd9e57d4c38675d321731d65c15258f3a66438ad531ae09cb8bb14217dc8572",
@@ -82,6 +102,35 @@ filegroup(
82102
)
83103
"""
84104

105+
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
106+
107+
llvm_toolchain(
108+
name = "llvm_toolchain",
109+
llvm_version = "14.0.0",
110+
sha256 = {
111+
"darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368",
112+
"linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6",
113+
},
114+
strip_prefix = {
115+
"darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin",
116+
"linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu",
117+
},
118+
sysroot = {
119+
"darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
120+
"darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
121+
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
122+
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
123+
},
124+
urls = {
125+
"darwin-aarch64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-arm64-apple-darwin.tar.xz"],
126+
"linux-x86_64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu.tar.xz"],
127+
},
128+
)
129+
130+
load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains")
131+
132+
register_llvm_toolchains()
133+
85134
http_archive(
86135
name = "org_chromium_sysroot_linux_arm64",
87136
build_file_content = _SYSROOT_LINUX_BUILD_FILE,
@@ -108,9 +157,11 @@ http_archive(
108157

109158
http_archive(
110159
name = "io_bazel_rules_go",
111-
sha256 = "6244c70a3102bacd9f823b666258d4d66550cd499f3cf957000b46bebf3a8c1f",
112-
strip_prefix = "rules_go-9d1456e778a36dab6d5cab3f68af3060cc869e2f",
113-
urls = ["https://github.com/bazelbuild/rules_go/archive/9d1456e778a36dab6d5cab3f68af3060cc869e2f.zip"],
160+
sha256 = "67b4d1f517ba73e0a92eb2f57d821f2ddc21f5bc2bd7a231573f11bd8758192e",
161+
urls = [
162+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
163+
"https://github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
164+
],
114165
)
115166

116167
http_archive(
@@ -273,35 +324,6 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
273324

274325
bazel_skylib_workspace()
275326

276-
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
277-
278-
llvm_toolchain(
279-
name = "llvm_toolchain",
280-
llvm_version = "14.0.0",
281-
sha256 = {
282-
"darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368",
283-
"linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6",
284-
},
285-
strip_prefix = {
286-
"darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin",
287-
"linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu",
288-
},
289-
sysroot = {
290-
"darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
291-
"darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
292-
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
293-
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
294-
},
295-
urls = {
296-
"darwin-aarch64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-arm64-apple-darwin.tar.xz"],
297-
"linux-x86_64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu.tar.xz"],
298-
},
299-
)
300-
301-
load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains")
302-
303-
register_llvm_toolchains()
304-
305327
load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
306328

307329
buildifier_prebuilt_register_toolchains()

release/BUILD.bazel

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
2+
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
23
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
34
load(":bazelisk_artifacts.bzl", "bazelisk_artifacts")
45
load(":release.bzl", "multi_platform_binaries", "release")
@@ -18,8 +19,26 @@ expand_template(
1819
template = ["0.0.0-PLACEHOLDER"],
1920
)
2021

22+
platform_transition_filegroup(
23+
name = "aspect-windows-x86_64.exe",
24+
srcs = ["//cmd/aspect"],
25+
tags = ["manual"],
26+
target_compatible_with = [
27+
"@platforms//os:windows",
28+
"@platforms//cpu:x86_64",
29+
],
30+
target_platform = "@zig_sdk//platform:windows_x86_64",
31+
)
32+
2133
bazelisk_artifacts(
22-
name = "aspect_bazelisk_artifacts",
34+
name = "windows_artifacts",
35+
tags = ["manual"],
36+
version_file = ":aspect_version",
37+
windows_x86_64 = ":aspect-windows-x86_64.exe",
38+
)
39+
40+
bazelisk_artifacts(
41+
name = "linux_and_darwin_artifacts",
2342
darwin_arm64 = ":aspect-macos-aarch64",
2443
darwin_x86_64 = ":aspect-macos-x86_64",
2544
linux_arm64 = ":aspect-linux-aarch64",
@@ -33,7 +52,16 @@ release(
3352
tags = ["manual"],
3453
targets = [
3554
":aspect",
36-
":aspect_bazelisk_artifacts",
55+
":linux_and_darwin_artifacts",
56+
],
57+
)
58+
59+
release(
60+
name = "release.windows",
61+
tags = ["manual"],
62+
targets = [
63+
":aspect-windows-x86_64.exe",
64+
":windows_artifacts",
3765
],
3866
)
3967

@@ -50,7 +78,7 @@ sh_binary(
5078
srcs = ["delivery.sh"],
5179
data = [
5280
":aspect",
53-
":aspect_bazelisk_artifacts",
81+
":linux_and_darwin_artifacts",
5482
],
5583
)
5684

@@ -61,7 +89,7 @@ sh_binary(
6189
srcs = ["delivery.sh"],
6290
data = [
6391
":aspect",
64-
":aspect_bazelisk_artifacts",
92+
":linux_and_darwin_artifacts",
6593
],
6694
tags = ["deliverable"],
6795
)

0 commit comments

Comments
 (0)