Skip to content

Commit

Permalink
Fix distribution tarballs and update changelog and version for releas…
Browse files Browse the repository at this point in the history
…e 1.4.0 (#429)

* Fix location of MODULE.bazel in distro tarballs.
* Remove invalid paths from WORKSPACE files in distro tarballs
* The resulting tarballs should finally be distributable as 1.4.0 in BCR.
  • Loading branch information
tetromino committed Jan 27, 2023
1 parent 99a6bcb commit 9cbe3ae
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 23 deletions.
1 change: 1 addition & 0 deletions BUILD
Expand Up @@ -10,6 +10,7 @@ package(default_visibility = ["//visibility:public"])
exports_files([
"LICENSE",
"MODULE.bazel",
"WORKSPACE",
])

filegroup(
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,15 @@
Release 1.4.0

**New Features**
- The Gazelle plugin is marked stable for general use (#400, #424)

**Other Notable Changes**
- copy_file/copy_directory again allow sandboxing (#392)

**Contributors**
Alexandre Rostovtsev, Nick Gooding, Simon Stewart, Xùdōng Yáng


Release 1.3.0

**New Features**
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
@@ -1,7 +1,7 @@
module(
name = "bazel_skylib",
# Keep in sync with version.bzl and @bazel_skylib_gazelle_plugin//:MODULE.bazel
version = "1.3.0",
version = "1.4.0",
compatibility_level = 1,
)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -144,7 +144,7 @@ load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugi

bazel_skylib_gazelle_plugin_workspace()

load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup"
load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup")

bazel_skylib_gazelle_plugin_setup()
```
Expand All @@ -163,7 +163,7 @@ gazelle(
gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@bazel_skylib_gazelle_plugin//gazelle/bzl",
"@bazel_skylib_gazelle_plugin//bzl",
],
)
```
13 changes: 7 additions & 6 deletions WORKSPACE
@@ -1,11 +1,16 @@
workspace(name = "bazel_skylib")

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

bazel_skylib_workspace()

### INTERNAL ONLY - lines after this are not included in the release packaging.
# Lines below are for tests, documentation generation, and distribution archive
# generation only, and should thus not be included by dependencies on bazel-skylib.

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

local_repository(
name = "bazel_skylib_gazelle_plugin",
path = "gazelle",
Expand All @@ -19,10 +24,6 @@ load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_se

bazel_skylib_gazelle_plugin_setup()

# Below this line is for documentation generation only,
# and should thus not be included by dependencies on
# bazel-skylib.

maybe(
http_archive,
name = "io_bazel_stardoc",
Expand Down
39 changes: 32 additions & 7 deletions distribution/BUILD
@@ -1,3 +1,4 @@
load("distribution.bzl", "remove_internal_only")
load("@bazel_skylib//:version.bzl", "version")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
Expand All @@ -6,18 +7,32 @@ package(
default_visibility = ["//visibility:private"],
)

genrule(
remove_internal_only(
name = "distro_workspace",
src = "//:WORKSPACE",
out = "WORKSPACE",
)

remove_internal_only(
name = "distro_module_bazel",
srcs = ["//:MODULE.bazel"],
outs = ["MODULE.bazel"],
cmd = "sed -e '/### INTERNAL ONLY/,$$d' $(location //:MODULE.bazel) >$@",
src = "//:MODULE.bazel",
out = "MODULE.bazel",
)

# remove "distribution/" path prefix
pkg_files(
name = "distro-files-without-prefix",
srcs = [
"distro_module_bazel",
"distro_workspace",
],
strip_prefix = strip_prefix.from_pkg(),
)

# Build the artifacts to put on the github release page.
pkg_tar(
name = "bazel-skylib",
srcs = [
"distro_module_bazel",
"distro-files-without-prefix",
"//:distribution",
],
out = "bazel-skylib-%s.tar.gz" % version,
Expand All @@ -28,6 +43,14 @@ pkg_tar(
strip_prefix = strip_prefix.from_root(),
)

# @bazel_skylib_gazelle_plugin//:WORKSPACE refers to bazel-skylib in the parent
# directory. For distribution, use the minimal WORSKPACE.bzlmod instead.
pkg_files(
name = "bazel-skylib-gazelle-plugin-distro_workspace",
srcs = ["@bazel_skylib_gazelle_plugin//:WORKSPACE.bzlmod"],
renames = {"@bazel_skylib_gazelle_plugin//:WORKSPACE.bzlmod": "WORKSPACE"},
)

pkg_files(
name = "bazel-skylib-gazelle-plugin-without-external-prefix",
srcs = [
Expand All @@ -40,7 +63,8 @@ pkg_files(
pkg_tar(
name = "bazel-skylib-gazelle-plugin",
srcs = [
":bazel-skylib-gazelle-plugin-without-external-prefix",
"bazel-skylib-gazelle-plugin-distro_workspace",
"bazel-skylib-gazelle-plugin-without-external-prefix",
"//:LICENSE",
],
out = "bazel-skylib-gazelle-plugin-%s.tar.gz" % version,
Expand All @@ -50,6 +74,7 @@ pkg_tar(
owner = "0.0",
)

# Build the artifacts to put on the github release page.
filegroup(
name = "distribution",
srcs = [
Expand Down
32 changes: 32 additions & 0 deletions distribution/distribution.bzl
@@ -0,0 +1,32 @@
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# 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.

"""Helper utilities for generating distribution tarballs."""

def remove_internal_only(name, src, out, **kwargs):
"""Removes '### INTERNAL ONLY' line and all lines below from a file.
Args:
name: Name of the rule.
src: File to process.
out: Path of the output file.
**kwargs: further keyword arguments.
"""
native.genrule(
name = name,
srcs = [src],
outs = [out],
cmd = "sed -e '/### INTERNAL ONLY/,$$d' $< >$@",
**kwargs
)
13 changes: 9 additions & 4 deletions gazelle/BUILD
@@ -1,5 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files(["WORKSPACE.bzlmod"])

bzl_library(
name = "setup",
srcs = ["setup.bzl"],
Expand All @@ -24,9 +26,12 @@ bzl_library(
# TODO(arostovtsev): exclude everything below from distro tarball
filegroup(
name = "distribution",
srcs = glob(
["*"],
allow_empty = True,
),
srcs = [
"BUILD",
"MODULE.bazel",
"WORKSPACE.bzlmod",
"setup.bzl",
"workspace.bzl",
],
visibility = ["//visibility:public"],
)
4 changes: 2 additions & 2 deletions gazelle/MODULE.bazel
@@ -1,12 +1,12 @@
module(
name = "bazel_skylib_gazelle_plugin",
# Keep in sync with @bazel_skylib//:MODULE.bazel and @bazel_skylib//:version.bzl
version = "1.3.0",
version = "1.4.0",
compatibility_level = 1,
)

# Keep in sync with @bazel_skylib//:MODULE.bazel and @bazel_skylib//:version.bzl
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "bazel_skylib", version = "1.4.0")
bazel_dep(name = "gazelle", version = "0.28.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.35.0", repo_name = "io_bazel_rules_go")

Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Expand Up @@ -14,4 +14,4 @@
"""The version of bazel-skylib."""

# Keep in sync with MODULE.bazel and @bazel_skylib_gazelle_plugin//:MODULE.bazel
version = "1.3.0"
version = "1.4.0"

0 comments on commit 9cbe3ae

Please sign in to comment.