Skip to content

Commit

Permalink
chore: update release rules & target to match silo (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Jun 10, 2023
1 parent c5f37b5 commit 9b1eb3b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 88 deletions.
48 changes: 0 additions & 48 deletions bazel/hash/BUILD.bazel

This file was deleted.

23 changes: 0 additions & 23 deletions bazel/hash/sha256.bzl

This file was deleted.

9 changes: 4 additions & 5 deletions release/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ version_file(

bazelisk_artifacts(
name = "aspect_bazelisk_artifacts",
darwin_arm64 = ":aspect-darwin-arm64",
darwin_x86_64 = ":aspect-darwin-amd64",
linux_arm64 = ":aspect-linux-arm64",
linux_x86_64 = ":aspect-linux-amd64",
darwin_arm64 = ":aspect-macos-aarch64",
darwin_x86_64 = ":aspect-macos-x86_64",
linux_arm64 = ":aspect-linux-aarch64",
linux_x86_64 = ":aspect-linux-x86_64",
tags = ["manual"],
version_file = ":aspect_version",
windows_x86_64 = ":aspect-windows-amd64",
)

cli_brew_artifacts(
Expand Down
22 changes: 11 additions & 11 deletions release/bazelisk_artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ _ATTRS = {
mandatory = True,
allow_single_file = True,
),
"windows_x86_64": attr.label(
doc = "The artifact for the linux-arm64 platform.",
mandatory = True,
allow_single_file = True,
"_sha256sum": attr.label(
executable = True,
cfg = "exec",
default = "//release/sha256sum",
),
}

Expand All @@ -46,10 +46,10 @@ def _impl(ctx):
ctx.file.darwin_x86_64,
ctx.file.linux_arm64,
ctx.file.linux_x86_64,
ctx.file.windows_x86_64,
]

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)
Expand All @@ -60,17 +60,16 @@ def _impl(ctx):
args.add("linux-arm64")
args.add(ctx.file.linux_x86_64)
args.add("linux-x86_64")
args.add(ctx.file.windows_x86_64)
args.add("windows-x86_64.exe")

ctx.actions.run_shell(
outputs = [outdir],
inputs = inputs,
arguments = [args],
command = """\
output_dir="$1"
version_file="$2"
shift 2
sha256sum="${PWD}/$1"
output_dir="$2"
version_file="$3"
shift 3
version="$(< "${version_file}")"
Expand All @@ -87,10 +86,11 @@ while (("$#")); do
cp "${artifact_path}" "${output_dir}/bazel-${version}-${platform_suffix}"
(
cd "${output_dir}"
sha256sum "bazel-${version}-${platform_suffix}" > "bazel-${version}-${platform_suffix}.sha256"
"${sha256sum}" "bazel-${version}-${platform_suffix}" > "bazel-${version}-${platform_suffix}.sha256"
)
done
""",
tools = [ctx.executable._sha256sum],
)

return [
Expand Down
1 change: 0 additions & 1 deletion release/brew/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ bzl_library(
srcs = ["brew_bottle.bzl"],
visibility = ["//visibility:public"],
deps = [
"//bazel/hash:sha256",
"@bazel_skylib//lib:paths",
"@rules_pkg//pkg:mappings.bzl",
"@rules_pkg//pkg:tar.bzl",
Expand Down
16 changes: 16 additions & 0 deletions release/sha256sum/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "sha256sum_lib",
srcs = ["main.go"],
importpath = "aspect.build/cli/release/sha256sum",
visibility = ["//visibility:private"],
)

go_binary(
name = "sha256sum",
embed = [":sha256sum_lib"],
visibility = [
"//release:__pkg__",
],
)
48 changes: 48 additions & 0 deletions release/sha256sum/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2022 Aspect Build Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package main

import (
"crypto/sha256"
"fmt"
"io"
"log"
"os"
)

func main() {
var input io.Reader
var filename string
if len(os.Args) == 1 {
input = os.Stdin
filename = "-"
} else {
f, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer f.Close()
input = f
filename = os.Args[1]
}

hash := sha256.New()
if _, err := io.Copy(hash, input); err != nil {
log.Fatal(err)
}
fmt.Printf("%x %s\n", hash.Sum(nil), filename)
}

0 comments on commit 9b1eb3b

Please sign in to comment.