diff --git a/BUILD b/BUILD index 001dcb9..ca4d6d7 100644 --- a/BUILD +++ b/BUILD @@ -3,3 +3,11 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) exports_files(["LICENSE"]) + +filegroup( + name = "distribution", + srcs = [ + "LICENSE", + ], + visibility = ["@//distro:__pkg__"], +) diff --git a/WORKSPACE b/WORKSPACE index 8d3caad..3aa393c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,9 +4,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_federation", - url = "https://github.com/bazelbuild/bazel-federation/archive/a3e140a91ea9ea25b01ad0cc6fbfcaf74f65498f.zip", - sha256 = "026149d1273a87c634d2270004865fd7474420f88d5bd6ea8d8cd71f4b0f0542", - strip_prefix = "bazel-federation-a3e140a91ea9ea25b01ad0cc6fbfcaf74f65498f", + url = "https://github.com/bazelbuild/bazel-federation/archive/f0e5eda7f0cbfe67f126ef4dacb18c89039b0506.zip", # 2019-09-30 + sha256 = "33222ab7bcc430f1ff1db8788c2e0118b749319dd572476c4fd02322d7d15792", + strip_prefix = "bazel-federation-f0e5eda7f0cbfe67f126ef4dacb18c89039b0506", type = "zip", ) diff --git a/cc/BUILD b/cc/BUILD index 333a58a..21ee541 100644 --- a/cc/BUILD +++ b/cc/BUILD @@ -44,3 +44,14 @@ filegroup( ], visibility = ["//visibility:public"], ) + +# TODO(aiuto): Find a way to strip this rule from the distribution tarball. +filegroup( + name = "distribution", + srcs = glob([ + "**", + ]), + visibility = [ + "//distro:__pkg__", + ], +) diff --git a/cc/version.bzl b/cc/version.bzl new file mode 100644 index 0000000..4363594 --- /dev/null +++ b/cc/version.bzl @@ -0,0 +1,17 @@ +# Copyright 2019 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. + +"""Information about the present version of rules_cc.""" + +version = "0.0.1" diff --git a/distro/BUILD b/distro/BUILD new file mode 100644 index 0000000..2e07f40 --- /dev/null +++ b/distro/BUILD @@ -0,0 +1,30 @@ +package( + default_visibility = ["//visibility:private"], +) + +load("@rules_cc//cc:version.bzl", "version") +load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("@rules_pkg//releasing:defs.bzl", "print_rel_notes") + +# Build the artifact to put on the github release page. +pkg_tar( + name = "rules_cc-%s" % version, + srcs = [ + "//:distribution", + "//cc:distribution", + ], + extension = "tar.gz", + # It is all source code, so make it read-only. + mode = "0444", + # Make it owned by root so it does not have the uid of the CI robot. + owner = "0.0", + package_dir = ".", + strip_prefix = ".", +) + +print_rel_notes( + name = "relnotes", + outs = ["relnotes.txt"], + repo = "rules_cc", + version = version, +) diff --git a/distro/README.md b/distro/README.md new file mode 100644 index 0000000..086436c --- /dev/null +++ b/distro/README.md @@ -0,0 +1,11 @@ +# Package rules_cc + +```bash +bazel build :relnotes +cat ../bazel-bin/distro/relnotes.txt +tar tzf ../bazel-bin/distro/rules_cc-*.tar.gz +``` + +- Create a new release +- Copy/paste relnotes.txt into the notes. Adjust as needed. +- Upload the tar.gz file as an artifact. diff --git a/internal_deps.bzl b/internal_deps.bzl index ea51aeb..fda3634 100644 --- a/internal_deps.bzl +++ b/internal_deps.bzl @@ -14,7 +14,7 @@ """Dependencies that are needed for rules_cc tests and tools.""" -load("@bazel_federation//:repositories.bzl", "bazel_skylib", "protobuf", "rules_go") +load("@bazel_federation//:repositories.bzl", "bazel_skylib", "protobuf", "rules_go", "rules_pkg") load("@bazel_federation//:third_party_repositories.bzl", "abseil_py", "py_mock", "six", "zlib") def rules_cc_internal_deps(): @@ -22,6 +22,7 @@ def rules_cc_internal_deps(): bazel_skylib() protobuf() rules_go() + rules_pkg() abseil_py() py_mock() diff --git a/internal_setup.bzl b/internal_setup.bzl index 99e7d55..beee607 100644 --- a/internal_setup.bzl +++ b/internal_setup.bzl @@ -19,8 +19,10 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") # TODO(fweikert): Also load rules_go's setup.bzl file from the federation once it exists load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@bazel_federation//setup:rules_pkg.bzl", "rules_pkg_setup") def rules_cc_internal_setup(): bazel_skylib_workspace() go_rules_dependencies() go_register_toolchains() + rules_pkg_setup()