Skip to content
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

chore: add windows release #746

Merged
merged 11 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ import %workspace%/.aspect/bazelrc/javascript.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc

### YOUR PROJECT SPECIFIC OPTIONS GO HERE ###
common --enable_platform_specific_config

# Allow our init template folders to contain BUILD.bazel without it being a subpackage
# To update, run:
# find pkg/aspect/init/template -type d | paste -d, -s - | awk '{ print "common --deleted_packages="$1 }'
common --deleted_packages=pkg/aspect/init/template,pkg/aspect/init/template/tools,pkg/aspect/init/template/tools/format

common --workspace_status_command "${PWD}/workspace_status.sh"

common:release -c opt --stamp
common:release -c opt --stamp --workspace_status_command "${PWD}/tools/workspace_status.sh"

# bzlmod causes issues with LLVM toolchain
common --noenable_bzlmod
Expand All @@ -24,8 +18,10 @@ common --noenable_bzlmod
common --noincompatible_disallow_empty_glob

# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains.
common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --incompatible_enable_cc_toolchain_resolution --incompatible_enable_proto_toolchain_resolution
common:linux --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --incompatible_enable_proto_toolchain_resolution

build:windows --sandbox_add_mount_pair=C:\Temp

# Tell Bazel to pass the right flags for llvm-ar, not libtool, only needed on linux.
# See https://github.com/bazelbuild/bazel/blob/5c75d0acec21459bbb13520817e3806e1507e907/tools/cpp/unix_cc_toolchain_config.bzl#L1000-L1024
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: build
on:
push:
branches: ['main']
pull_request:
workflow_call:
outputs:
windows:
description: 'Windows binaries'
value: ${{jobs.build_windows.outputs.artifact}}
linux:
description: 'Linux and MacOS binaries'
value: ${{jobs.build.outputs.artifact}}
jobs:
build:
name: darwin and linux
runs-on: ubuntu-latest
outputs:
artifact: ${{steps.upload.outputs.artifact-url}}
steps:
- uses: actions/checkout@v4
- run: |
bazel run --config=release //release -- /tmp/aspect/release
- uses: actions/upload-artifact@v4
id: upload
with:
name: linux
retention-days: 1
path: /tmp/aspect/release
# Cross-compiling to Windows is too hard. Just build on a windows runner instead.
build_windows:
name: windows
runs-on: windows-2022
outputs:
artifact: ${{steps.upload.outputs.artifact-url}}
env:
USE_BAZEL_VERSION: 7.2.1
BAZELISK_BASE_URL: https://github.com/bazelbuild/bazel/releases/download
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
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
thesayyn marked this conversation as resolved.
Show resolved Hide resolved
- name: smoke test
run: ./aspect_windows_amd64.exe --help
- uses: actions/upload-artifact@v4
id: upload
with:
name: windows
retention-days: 1
path: aspect_windows_amd64.exe
32 changes: 14 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
name: Release
on:
# Allow manual testing by invoking this workflow from the GH web UI
workflow_dispatch:
push:
tags:
- '202*.*.*'
jobs:
build:
build_all:
uses: ./.github/workflows/build.yaml
release:
runs-on: ubuntu-latest
needs: build_all
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
fetch-depth: 0
- name: Build release artifacts
run: |
if [ -n "$(git status --porcelain)" ]; then
>&2 echo "ERROR: the git state is not clean, aborting build..."
exit 1
fi
rm -rf /tmp/aspect/release
bazel run --config=release //release -- /tmp/aspect/release
if /tmp/aspect/release/aspect-linux_amd64 version | grep '(with local changes)'; then
>&2 echo "ERROR: the release contained changes in the git state and the release will not be produced"
exit 1
fi
merge-multiple: true
- run: shasum -a 256 aspect* > SHA256.txt
- name: Prepare workspace snippet
run: .github/workflows/install_snippet.sh > release_notes.txt
- name: Create GitHub draft release and upload artifacts
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
files: /tmp/aspect/release/*
files: |
aspect*
SHA256.txt
86 changes: 54 additions & 32 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ workspace(name = "build_aspect_cli")

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

HERMETIC_CC_TOOLCHAIN_VERSION = "v3.1.1"

http_archive(
name = "hermetic_cc_toolchain",
sha256 = "907745bf91555f77e8234c0b953371e6cac5ba715d1cf12ff641496dd1bce9d1",
urls = [
"https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
"https://github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
],
)

load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains")

zig_toolchains()

register_toolchains(
"@zig_sdk//toolchain:windows_amd64",
"@zig_sdk//toolchain:windows_arm64",
)

http_archive(
name = "bazel_features",
sha256 = "2cd9e57d4c38675d321731d65c15258f3a66438ad531ae09cb8bb14217dc8572",
Expand Down Expand Up @@ -82,6 +102,35 @@ filegroup(
)
"""

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "14.0.0",
sha256 = {
"darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368",
"linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6",
},
strip_prefix = {
"darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin",
"linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu",
},
sysroot = {
"darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
"darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
},
urls = {
"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"],
"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"],
},
)

load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains")

register_llvm_toolchains()

http_archive(
name = "org_chromium_sysroot_linux_arm64",
build_file_content = _SYSROOT_LINUX_BUILD_FILE,
Expand All @@ -108,9 +157,11 @@ http_archive(

http_archive(
name = "io_bazel_rules_go",
sha256 = "6244c70a3102bacd9f823b666258d4d66550cd499f3cf957000b46bebf3a8c1f",
strip_prefix = "rules_go-9d1456e778a36dab6d5cab3f68af3060cc869e2f",
urls = ["https://github.com/bazelbuild/rules_go/archive/9d1456e778a36dab6d5cab3f68af3060cc869e2f.zip"],
sha256 = "67b4d1f517ba73e0a92eb2f57d821f2ddc21f5bc2bd7a231573f11bd8758192e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
],
)

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

bazel_skylib_workspace()

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "14.0.0",
sha256 = {
"darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368",
"linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6",
},
strip_prefix = {
"darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin",
"linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu",
},
sysroot = {
"darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
"darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
},
urls = {
"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"],
"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"],
},
)

load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains")

register_llvm_toolchains()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()
Expand Down
11 changes: 11 additions & 0 deletions release/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":bazelisk_artifacts.bzl", "bazelisk_artifacts")
load(":release.bzl", "multi_platform_binaries", "release")
Expand All @@ -18,6 +19,16 @@ expand_template(
template = ["0.0.0-PLACEHOLDER"],
)

platform_transition_filegroup(
name = "aspect_windows_amd64",
srcs = ["//cmd/aspect"],
target_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
target_platform = "@zig_sdk//platform:windows_x86_64",
)

bazelisk_artifacts(
name = "aspect_bazelisk_artifacts",
darwin_arm64 = ":aspect-macos-aarch64",
Expand Down
File renamed without changes.
Loading