Use rules_pkg to make the skylib tarball for a release. (#185)

* add empty CHANGELOG.md to try to reuse bazel release.sh

* checkpoint a new distribution method

* Update CHANGELOG.

* checkpoint relnew

* get the tarball working

* fix visibilyt

* whitespace

* punctuation typos

* buildify

* linty fresh
diff --git a/BUILD b/BUILD
index 6630132..385f0fe 100644
--- a/BUILD
+++ b/BUILD
@@ -47,3 +47,19 @@
     name = "bzl_library",
     srcs = ["bzl_library.bzl"],
 )
+
+# The files needed for distribution.
+# TODO(aiuto): We should strip this from the release, but there is no
+# capability now to generate BUILD.foo from BUILD and have it appear in the
+# tarball as BUILD.
+filegroup(
+    name = "distribution",
+    srcs = [
+        "LICENSE",
+        "BUILD",
+        "CODEOWNERS",
+        "CONTRIBUTORS",
+        "//lib:distribution",
+        "//rules:distribution",
+    ] + glob(["*.bzl"]),
+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..3c58c55
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,45 @@
+**New Features**
+
+-   common_settings.bzl: Standard data types for user defined build
+    configuration. Common scalar build settings for rules to use so they don't
+    recreate them locally. This fulfills part of the SBC design doc:
+    https://docs.google.com/document/d/1vc8v-kXjvgZOdQdnxPTaV0rrLxtP2XwnD2tAZlYJOqw/edit#bookmark=id.iiumwic0jphr
+-   selects.bzl: Add config_setting_group for config_setting AND/OR-chaining
+    Implements
+    https://github.com/bazelbuild/proposals/blob/master/designs/2018-11-09-config-setting-chaining.md.
+-   Make sets.bzl point to new_sets.bzl instead of old_sets.bzl. new_sets.bzl
+    and old_sets.bzl should be removed in the following skylib release.
+
+-   run_binary: runs an executable as an action
+
+    -   This rule is an alternative for genrule(): it can run a binary with the
+        desired arguments, environment, inputs, and outputs, as a single build
+        action, without shelling out to Bash.
+    -   Fixes https://github.com/bazelbuild/bazel-skylib/issues/149
+
+-   New `native_binary()` and `native_test()` rules let you wrap a pre-built
+    binary in a binary and test rule respectively.
+
+    -   native_binary() wraps a pre-built binary or script in a *_binary rule
+        interface. Rules like genrule can tool-depend on it, and it can be
+        executed with "bazel run". This rule can also augment the binary with
+        runfiles.
+    -   native_test() is similar, but creates a testable rule instead of a
+        binary rule.
+    -   Fixes https://github.com/bazelbuild/bazel-skylib/issues/148
+
+-   diff_test: test rule compares two files and passes if the files match.
+
+    On Linux/macOS/non-Windows, the test compares files using 'diff'.
+
+    On Windows, the test compares files using 'fc.exe'. This utility is
+    available on all Windows versions I tried (Windows 2008 Server, Windows 2016
+    Datacenter Core).
+
+    See https://github.com/bazelbuild/bazel/issues/5508,
+    https://github.com/bazelbuild/bazel/issues/4319
+
+-   maprule: move functionality to maprule_util.bzl. maprule_util.bzl will
+    benefit planned new rules (namely a genrule alternative).
+
+**This release is tested with Bazel 0.28**
diff --git a/distribution/BUILD b/distribution/BUILD
new file mode 100644
index 0000000..df69e0c
--- /dev/null
+++ b/distribution/BUILD
@@ -0,0 +1,29 @@
+package(
+    default_visibility = ["//visibility:private"],
+)
+
+load("@bazel_skylib//: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 = "bazel-skylib-%s" % version,
+    srcs = [
+        "//: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 = "bazel-skylib",
+    version = version,
+)
diff --git a/internal_deps.bzl b/internal_deps.bzl
index 5db0890..c7dacd8 100644
--- a/internal_deps.bzl
+++ b/internal_deps.bzl
@@ -14,8 +14,14 @@
 
 """Dependencies that are needed for running skylib tests."""
 
-load("@bazel_federation//:repositories.bzl", "bazel", "bazel_stardoc")
+load(
+    "@bazel_federation//:repositories.bzl",
+    "bazel",
+    "bazel_stardoc",
+    "rules_pkg",
+)
 
 def bazel_skylib_internal_deps():
     bazel()
     bazel_stardoc()
+    rules_pkg()
diff --git a/lib/BUILD b/lib/BUILD
index dd56187..8ae8259 100644
--- a/lib/BUILD
+++ b/lib/BUILD
@@ -4,12 +4,6 @@
 
 package(default_visibility = ["//visibility:public"])
 
-filegroup(
-    name = "test_deps",
-    testonly = True,
-    srcs = ["BUILD"] + glob(["*.bzl"]),
-)
-
 bzl_library(
     name = "collections",
     srcs = ["collections.bzl"],
@@ -78,3 +72,19 @@
     name = "versions",
     srcs = ["versions.bzl"],
 )
+
+filegroup(
+    name = "test_deps",
+    testonly = True,
+    srcs = ["BUILD"] + glob(["*.bzl"]),
+)
+
+# The files needed for distribution
+filegroup(
+    name = "distribution",
+    srcs = glob(["*"]),
+    visibility = [
+        "//:__pkg__",
+        "//distribution:__pkg__",
+    ],
+)
diff --git a/rules/BUILD b/rules/BUILD
index a22dd46..a977212 100644
--- a/rules/BUILD
+++ b/rules/BUILD
@@ -56,3 +56,13 @@
         "empty_test.sh",
     ] + glob(["*.bzl"]),
 )
+
+# The files needed for distribution
+filegroup(
+    name = "distribution",
+    srcs = glob(["*"]),
+    visibility = [
+        "//:__pkg__",
+        "//distribution:__pkg__",
+    ],
+)
diff --git a/version.bzl b/version.bzl
new file mode 100644
index 0000000..1d02870
--- /dev/null
+++ b/version.bzl
@@ -0,0 +1,16 @@
+# 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.
+"""The version of bazel-skylib."""
+
+version = "0.10.0"