Skip to content

Commit

Permalink
Fix prerelease (#708)
Browse files Browse the repository at this point in the history
* fix: use source toolchains for git archive prereleases

* Add comment about "g" prefix
  • Loading branch information
alexeagle authored Jan 4, 2024
1 parent d313c8b commit 1be6994
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ load("//lib/private:jq_toolchain.bzl", "JQ_PLATFORMS", "jq_host_alias_repo", "jq
load("//lib/private:source_toolchains_repo.bzl", "source_toolchains_repo")
load("//lib/private:tar_toolchain.bzl", "BSDTAR_PLATFORMS", "bsdtar_binary_repo", "tar_toolchains_repo")
load("//lib/private:yq_toolchain.bzl", "YQ_PLATFORMS", "yq_host_alias_repo", "yq_platform_repo", "yq_toolchains_repo", _DEFAULT_YQ_VERSION = "DEFAULT_YQ_VERSION")
load("//tools:version.bzl", "VERSION")
load("//tools:version.bzl", "IS_PRERELEASE")

# buildifier: disable=unnamed-macro
def aspect_bazel_lib_dependencies():
Expand Down Expand Up @@ -215,7 +215,7 @@ def register_copy_directory_toolchains(name = DEFAULT_COPY_DIRECTORY_REPOSITORY,
register: whether to call through to native.register_toolchains.
Should be True for WORKSPACE users, but false when used under bzlmod extension
"""
if VERSION == "0.0.0":
if IS_PRERELEASE:
source_toolchains_repo(
name = "%s_toolchains" % name,
toolchain_type = "@aspect_bazel_lib//lib:copy_directory_toolchain_type",
Expand Down Expand Up @@ -250,7 +250,7 @@ def register_copy_to_directory_toolchains(name = DEFAULT_COPY_TO_DIRECTORY_REPOS
register: whether to call through to native.register_toolchains.
Should be True for WORKSPACE users, but false when used under bzlmod extension
"""
if VERSION == "0.0.0":
if IS_PRERELEASE:
source_toolchains_repo(
name = "%s_toolchains" % name,
toolchain_type = "@aspect_bazel_lib//lib:copy_to_directory_toolchain_type",
Expand Down Expand Up @@ -285,7 +285,7 @@ def register_expand_template_toolchains(name = DEFAULT_EXPAND_TEMPLATE_REPOSITOR
register: whether to call through to native.register_toolchains.
Should be True for WORKSPACE users, but false when used under bzlmod extension
"""
if VERSION == "0.0.0":
if IS_PRERELEASE:
source_toolchains_repo(
name = "%s_toolchains" % name,
toolchain_type = "@aspect_bazel_lib//lib:expand_template_toolchain_type",
Expand Down
8 changes: 8 additions & 0 deletions tools/version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
_VERSION_PRIVATE = "$Format:%(describe:tags=true)$"

VERSION = "0.0.0" if _VERSION_PRIVATE.startswith("$Format") else _VERSION_PRIVATE.replace("v", "", 1)

# Whether bazel-lib is a pre-release, and therefore has no release artifacts to download.
# NB: When GitHub runs `git archive` to serve a source archive file,
# it honors our .gitattributes and stamps this file, e.g.
# _VERSION_PRIVATE = "v2.0.3-7-g57bfe2c1"
# From https://git-scm.com/docs/git-describe:
# > The "g" prefix stands for "git"
IS_PRERELEASE = VERSION == "0.0.0" or VERSION.find("g") >= 0

0 comments on commit 1be6994

Please sign in to comment.