fix(ci): always build with -c opt (#555)
We no longer stamp our version anywhere since the Go tools must have deterministic hashes, so remove the --stamp setup
diff --git a/.bazelrc b/.bazelrc
index e068fc4..25173fe 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -19,13 +19,7 @@
# Mock versioning command to test the --stamp behavior
build --workspace_status_command="echo BUILD_SCM_VERSION 1.2.3"
-# For releasing, use --workspace_status_command and stamp
-# before adding more flags to the release config make sure it does not
-# affect the hashes of /tools. See tools/release.bzl for opt transition
-# add appropriate commandline transition there to match the configuration.
-common:release --workspace_status_command "${PWD}/workspace_status.sh"
-common:release -c opt
-common:release --stamp
+common --compilation_mode opt
# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b8c3c0e..8fbe4f1 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -26,8 +26,7 @@
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
- # Warning: DO NOT drop --config=release as it ensures that tools/integrity.bzl is up-to-date with release config.
- run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //... --config=release
+ run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
- name: Build release artifacts
run: |
if [ -n "$(git status --porcelain)" ]; then
@@ -35,7 +34,7 @@
exit 1
fi
rm -rf /tmp/aspect/release
- bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run --config=release //tools:release -- /tmp/aspect/release
+ bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run //tools:release -- /tmp/aspect/release
if /tmp/aspect/release/copy_to_directory-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
diff --git a/tools/release.bzl b/tools/release.bzl
index 15fcfc0..79cf2bb 100644
--- a/tools/release.bzl
+++ b/tools/release.bzl
@@ -14,36 +14,6 @@
struct(os = "windows", arch = "amd64", ext = ".exe", gc_linkopts = []),
]
-def _compilation_mode_transition_impl(settings, attr):
- # buildifier: disable=unused-variable
- _ignore = (settings, attr)
- return {"//command_line_option:compilation_mode": "opt"}
-
-compilation_mode_transition = transition(
- implementation = _compilation_mode_transition_impl,
- inputs = [],
- outputs = ["//command_line_option:compilation_mode"],
-)
-
-def _compilation_mode_transition_rule_impl(ctx):
- runfiles = ctx.runfiles().merge_all([target[DefaultInfo].default_runfiles for target in ctx.attr.targets])
-
- return DefaultInfo(
- files = depset(ctx.files.targets),
- runfiles = runfiles,
- )
-
-compilation_mode_transition_rule = rule(
- implementation = _compilation_mode_transition_rule_impl,
- attrs = {
- "targets": attr.label_list(),
- "_allowlist_function_transition": attr.label(
- default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
- ),
- },
- cfg = compilation_mode_transition,
-)
-
def multi_platform_go_binaries(name, embed, prefix = "", **kwargs):
"""The multi_platform_go_binaries macro creates a go_binary for each platform.
@@ -79,10 +49,9 @@
)
targets.extend([target_label, hashes_label])
- # binaries should always be compiled in opt mode as it affects the hashes.
- compilation_mode_transition_rule(
+ native.filegroup(
name = name,
- targets = targets,
+ srcs = targets,
**kwargs
)
diff --git a/workspace_status.sh b/workspace_status.sh
deleted file mode 100755
index ee5aa59..0000000
--- a/workspace_status.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env bash
-set -o errexit -o nounset -o pipefail
-
-# This script is called by Bazel when it needs info about the git state.
-# The --workspace_status_command flag tells Bazel the location of this script.
-# This is configured in `/.bazelrc`.
-set -o pipefail -o errexit -o nounset
-
-function has_local_changes {
- if [ "$(git status --porcelain)" != "" ]; then
- echo dirty
- else
- echo clean
- fi
-}
-
-# "stable" keys, should remain constant over rebuilds, therefore changed values will cause a
-# rebuild of any stamped action that uses ctx.info_file or genrule with stamp = True
-# Note, BUILD_USER is automatically available in the stable-status.txt, it matches $USER
-echo "STABLE_BUILD_SCM_SHA $(git rev-parse HEAD)"
-echo "STABLE_BUILD_SCM_LOCAL_CHANGES $(has_local_changes)"
-
-if [ -n "${STABLE_BUILD_SCM_TAG_OVERRIDE:-}" ]; then
- echo "STABLE_BUILD_SCM_TAG $STABLE_BUILD_SCM_TAG_OVERRIDE"
-elif [ "$(git tag | wc -l)" -gt 0 ]; then
- echo "STABLE_BUILD_SCM_TAG $(git describe --tags)"
-fi