diff --git a/BUILD.bazel b/BUILD.bazel index ce9f9a15..cbc75fe5 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,6 +1,5 @@ load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary") load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files") load( "//bzlformat:defs.bzl", "bzlformat_missing_pkgs", @@ -115,12 +114,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - visibility = ["//:__subpackages__"], -) - # All of the packages that should be included in the release archive and made # available to the child workspaces. _RUNTIME_PKGS = [ @@ -161,16 +154,6 @@ filegroup( ], visibility = [ ":integration_test_visibility", - ], -) - -pkg_filegroup( - name = "release_filegroup", - srcs = [ - pkg + ":release_files" - for pkg in _RUNTIME_PKGS - ], - visibility = [ "//:__subpackages__", ], ) diff --git a/WORKSPACE b/WORKSPACE index fbd49ebd..6a896a67 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -26,10 +26,6 @@ load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() -load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies() - # MARK: - Prebuilt Buildtools Deps load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps") diff --git a/bazeldoc/BUILD.bazel b/bazeldoc/BUILD.bazel index d0781e64..190a5724 100644 --- a/bazeldoc/BUILD.bazel +++ b/bazeldoc/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -30,10 +29,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bazeldoc/private/BUILD.bazel b/bazeldoc/private/BUILD.bazel index eac8362b..91b7a2ca 100644 --- a/bazeldoc/private/BUILD.bazel +++ b/bazeldoc/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//bazeldoc:__subpackages__"]) @@ -57,13 +56,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - bzl_library( name = "doc_utilities", srcs = ["doc_utilities.bzl"], diff --git a/build/BUILD.bazel b/build/BUILD.bazel index fedcb98a..b653593b 100644 --- a/build/BUILD.bazel +++ b/build/BUILD.bazel @@ -1,6 +1,5 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") bzlformat_pkg(name = "bzlformat") @@ -10,13 +9,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - string_flag( name = "execution_env", build_setting_default = "normal", diff --git a/bzlformat/BUILD.bazel b/bzlformat/BUILD.bazel index ae066229..942a4724 100644 --- a/bzlformat/BUILD.bazel +++ b/bzlformat/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat/private:bzlformat_pkg.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -30,10 +29,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzlformat/private/BUILD.bazel b/bzlformat/private/BUILD.bazel index 0e4f3863..d650c520 100644 --- a/bzlformat/private/BUILD.bazel +++ b/bzlformat/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load(":bzlformat_pkg.bzl", "bzlformat_pkg") package(default_visibility = ["//bzlformat:__subpackages__"]) @@ -52,10 +51,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzlformat/tools/BUILD.bazel b/bzlformat/tools/BUILD.bazel index 9debdd3c..496460b9 100644 --- a/bzlformat/tools/BUILD.bazel +++ b/bzlformat/tools/BUILD.bazel @@ -1,4 +1,3 @@ -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") # MARK: - Binaries @@ -24,10 +23,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzlformat/tools/missing_pkgs/BUILD.bazel b/bzlformat/tools/missing_pkgs/BUILD.bazel index f49eac6d..06a83870 100644 --- a/bzlformat/tools/missing_pkgs/BUILD.bazel +++ b/bzlformat/tools/missing_pkgs/BUILD.bazel @@ -1,4 +1,3 @@ -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") bzlformat_pkg(name = "bzlformat") @@ -46,10 +45,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzllib/BUILD.bazel b/bzllib/BUILD.bazel index fc28290f..bf26c3f9 100644 --- a/bzllib/BUILD.bazel +++ b/bzllib/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -31,10 +30,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzllib/private/BUILD.bazel b/bzllib/private/BUILD.bazel index 97af4151..7a41389d 100644 --- a/bzllib/private/BUILD.bazel +++ b/bzllib/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//bzllib:__subpackages__"]) @@ -14,13 +13,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - bzl_library( name = "bazel_labels", srcs = ["bazel_labels.bzl"], diff --git a/bzlrelease/BUILD.bazel b/bzlrelease/BUILD.bazel index b3ad4b09..0a17a5a2 100644 --- a/bzlrelease/BUILD.bazel +++ b/bzlrelease/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -20,6 +19,7 @@ bzl_library( "//bzlrelease/private:generate_release_notes", "//bzlrelease/private:generate_workspace_snippet", "//bzlrelease/private:hash_sha256", + "//bzlrelease/private:release_archive", "//bzlrelease/private:update_readme", ], ) @@ -31,10 +31,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzlrelease/defs.bzl b/bzlrelease/defs.bzl index 5f36d14e..c3a4d13b 100644 --- a/bzlrelease/defs.bzl +++ b/bzlrelease/defs.bzl @@ -13,6 +13,10 @@ load( _generate_workspace_snippet = "generate_workspace_snippet", ) load("//bzlrelease/private:hash_sha256.bzl", _hash_sha256 = "hash_sha256") +load( + "//bzlrelease/private:release_archive.bzl", + _release_archive = "release_archive", +) load( "//bzlrelease/private:update_readme.bzl", _update_readme = "update_readme", @@ -27,3 +31,5 @@ generate_release_notes = _generate_release_notes hash_sha256 = _hash_sha256 update_readme = _update_readme + +release_archive = _release_archive diff --git a/bzlrelease/private/BUILD.bazel b/bzlrelease/private/BUILD.bazel index 560a4139..a673d401 100644 --- a/bzlrelease/private/BUILD.bazel +++ b/bzlrelease/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//bzlrelease:__subpackages__"]) @@ -46,14 +45,12 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - bzl_library( name = "hash_sha256", srcs = ["hash_sha256.bzl"], ) + +bzl_library( + name = "release_archive", + srcs = ["release_archive.bzl"], +) diff --git a/bzlrelease/private/release_archive.bzl b/bzlrelease/private/release_archive.bzl new file mode 100644 index 00000000..04bc4859 --- /dev/null +++ b/bzlrelease/private/release_archive.bzl @@ -0,0 +1,63 @@ +"""Definition for `release_archive` rule.""" + +def _release_archive_impl(ctx): + out_basename = ctx.attr.out + if out_basename == "": + out_basename = "{name}{ext}".format( + name = ctx.label.name, + ext = ctx.attr.ext, + ) + out = ctx.actions.declare_file(out_basename) + + # Write the file list to a file + file_list_out = ctx.actions.declare_file(ctx.label.name + "_files") + file_list_args = ctx.actions.args() + file_list_args.add_all(ctx.files.srcs) + ctx.actions.write( + output = file_list_out, + content = file_list_args, + ) + + # Create the archive + args = ctx.actions.args() + args.add(out) + args.add(file_list_out) + ctx.actions.run_shell( + outputs = [out], + inputs = [file_list_out] + ctx.files.srcs, + arguments = [args], + command = """\ +archive="$1" +file_list="$2" +shift 1 +tar 2>/dev/null -hczvf "$archive" -T "${file_list}" +""", + ) + return DefaultInfo( + files = depset([out]), + runfiles = ctx.runfiles(files = [out]), + ) + +release_archive = rule( + implementation = _release_archive_impl, + attrs = { + "ext": attr.string( + default = ".tar.gz", + doc = "The extension for the archive.", + ), + "out": attr.string( + doc = "The name of the output file.", + ), + "srcs": attr.label_list( + allow_files = True, + mandatory = True, + ), + }, + doc = """\ +Create a source release archive. + +This rule uses `tar` to collect and compress files into an archive file \ +suitable for use as a release artifact. Any permissions on the source files \ +will be preserved. +""", +) diff --git a/bzlrelease/tools/BUILD.bazel b/bzlrelease/tools/BUILD.bazel index f73ae227..6559305d 100644 --- a/bzlrelease/tools/BUILD.bazel +++ b/bzlrelease/tools/BUILD.bazel @@ -1,4 +1,3 @@ -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") bzlformat_pkg(name = "bzlformat") @@ -115,10 +114,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzlrelease/tools/generate_sha256.sh b/bzlrelease/tools/generate_sha256.sh index c5158959..bf0025b5 100755 --- a/bzlrelease/tools/generate_sha256.sh +++ b/bzlrelease/tools/generate_sha256.sh @@ -69,7 +69,8 @@ case "${utility}" in openssl) function sumsha256() { # On Ubuntu, we can see a prefix of '(stdin)= ' - openssl dgst -sha256 | sed -E 's|^\(stdin\)= (.*)|\1|g' + # 2023-02-01: This has recently changed to be 'SHA2-256(stdin)='. + openssl dgst -sha256 | sed -E 's|^.*\(stdin\)= (.*)|\1|g' } ;; *) diff --git a/bzltidy/BUILD.bazel b/bzltidy/BUILD.bazel index f074ee83..1a37a5ff 100644 --- a/bzltidy/BUILD.bazel +++ b/bzltidy/BUILD.bazel @@ -1,6 +1,5 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") package(default_visibility = ["//visibility:public"]) @@ -26,10 +25,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/bzltidy/private/BUILD.bazel b/bzltidy/private/BUILD.bazel index 3f6332f5..d475aec2 100644 --- a/bzltidy/private/BUILD.bazel +++ b/bzltidy/private/BUILD.bazel @@ -1,6 +1,5 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") exports_files([ "tidy.sh", @@ -17,13 +16,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - bzl_library( name = "tidy", srcs = ["tidy.bzl"], diff --git a/deps.bzl b/deps.bzl index 8dc4e1d4..f806f298 100644 --- a/deps.bzl +++ b/deps.bzl @@ -108,16 +108,6 @@ def bazel_starlib_dependencies( ], ) - maybe( - http_archive, - name = "rules_pkg", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.8.0/rules_pkg-0.8.0.tar.gz", - "https://github.com/bazelbuild/rules_pkg/releases/download/0.8.0/rules_pkg-0.8.0.tar.gz", - ], - sha256 = "eea0f59c28a9241156a47d7a8e32db9122f3d50b505fae0f33de6ce4d9b61834", - ) - if use_bazeldoc: _bazeldoc_dependencies() diff --git a/doc/bzlrelease/BUILD.bazel b/doc/bzlrelease/BUILD.bazel index 08530003..42ee94f2 100644 --- a/doc/bzlrelease/BUILD.bazel +++ b/doc/bzlrelease/BUILD.bazel @@ -22,6 +22,7 @@ _RULE_NAMES = [ "generate_release_notes", "generate_workspace_snippet", "hash_sha256", + "release_archive", "update_readme", ] diff --git a/doc/bzlrelease/release_archive.md b/doc/bzlrelease/release_archive.md new file mode 100755 index 00000000..86d1f329 --- /dev/null +++ b/doc/bzlrelease/release_archive.md @@ -0,0 +1,28 @@ + +# `release_archive` Rule + + + + +## release_archive + +
+release_archive(name, ext, out, srcs)
+
+ +Create a source release archive. + +This rule uses `tar` to collect and compress files into an archive file suitable for use as a release artifact. Any permissions on the source files will be preserved. + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| ext | The extension for the archive. | String | optional | ".tar.gz" | +| out | The name of the output file. | String | optional | "" | +| srcs | - | List of labels | required | | + + diff --git a/doc/bzlrelease/rules.md b/doc/bzlrelease/rules.md index 3e54bdb8..3e760555 100755 --- a/doc/bzlrelease/rules.md +++ b/doc/bzlrelease/rules.md @@ -7,5 +7,6 @@ The rules listed below are available in this repository. * [generate_release_notes](/doc/bzlrelease/generate_release_notes.md) * [generate_workspace_snippet](/doc/bzlrelease/generate_workspace_snippet.md) * [hash_sha256](/doc/bzlrelease/hash_sha256.md) + * [release_archive](/doc/bzlrelease/release_archive.md) * [update_readme](/doc/bzlrelease/update_readme.md) diff --git a/markdown/BUILD.bazel b/markdown/BUILD.bazel index fd22fc4f..e370be14 100644 --- a/markdown/BUILD.bazel +++ b/markdown/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -12,13 +11,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - filegroup( name = "default_markdown_link_check_config", srcs = ["default_markdown_link_check_config.json"], diff --git a/markdown/private/BUILD.bazel b/markdown/private/BUILD.bazel index 1777b22b..0b88b704 100644 --- a/markdown/private/BUILD.bazel +++ b/markdown/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") bzlformat_pkg(name = "bzlformat") @@ -10,13 +9,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - bzl_library( name = "markdown_generate_toc", srcs = ["markdown_generate_toc.bzl"], diff --git a/markdown/tools/BUILD.bazel b/markdown/tools/BUILD.bazel index d1c439c9..41e20b7d 100644 --- a/markdown/tools/BUILD.bazel +++ b/markdown/tools/BUILD.bazel @@ -1,5 +1,4 @@ load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") bzlformat_pkg(name = "bzlformat") @@ -9,13 +8,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - sh_binary( name = "update_markdown_doc", srcs = ["update_markdown_doc.sh"], diff --git a/release/BUILD.bazel b/release/BUILD.bazel index 60a28010..8e6c444c 100644 --- a/release/BUILD.bazel +++ b/release/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("//bzlformat:defs.bzl", "bzlformat_pkg") load( "//bzlrelease:defs.bzl", @@ -7,6 +6,7 @@ load( "generate_release_notes", "generate_workspace_snippet", "hash_sha256", + "release_archive", "update_readme", ) @@ -41,11 +41,10 @@ create_release( workflow_name = "Create Release", ) -pkg_tar( +release_archive( name = "archive", - srcs = ["//:release_filegroup"], + srcs = ["//:local_repository_files"], out = "bazel-starlib.tar.gz", - extension = ".tar.gz", ) hash_sha256( diff --git a/shlib/lib/BUILD.bazel b/shlib/lib/BUILD.bazel index 6f33d4b5..ff919836 100644 --- a/shlib/lib/BUILD.bazel +++ b/shlib/lib/BUILD.bazel @@ -1,4 +1,3 @@ -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -62,10 +61,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/shlib/rules/BUILD.bazel b/shlib/rules/BUILD.bazel index 7ac91e7b..5a68b48d 100644 --- a/shlib/rules/BUILD.bazel +++ b/shlib/rules/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -30,10 +29,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/shlib/rules/private/BUILD.bazel b/shlib/rules/private/BUILD.bazel index 8623a0b3..9f848ae5 100644 --- a/shlib/rules/private/BUILD.bazel +++ b/shlib/rules/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//shlib/rules:__pkg__"]) @@ -39,10 +38,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/shlib/tools/BUILD.bazel b/shlib/tools/BUILD.bazel index e93f6525..7b9ecba5 100644 --- a/shlib/tools/BUILD.bazel +++ b/shlib/tools/BUILD.bazel @@ -1,4 +1,3 @@ -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") bzlformat_pkg(name = "bzlformat") @@ -19,10 +18,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/BUILD.bazel b/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/BUILD.bazel index ea9f2ae1..1010aee9 100644 --- a/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/BUILD.bazel +++ b/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/BUILD.bazel @@ -1,7 +1,6 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file") -load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("//bzlformat:defs.bzl", "bzlformat_pkg") -load("//bzlrelease:defs.bzl", "generate_workspace_snippet", "hash_sha256") +load("//bzlrelease:defs.bzl", "generate_workspace_snippet", "hash_sha256", "release_archive") load("//tests:integration_test_common.bzl", "GH_ENV_INHERIT", "INTEGRATION_TEST_TAGS") bzlformat_pkg(name = "bzlformat") @@ -21,7 +20,7 @@ write_file( content = ["Hello, World!"], ) -pkg_tar( +release_archive( name = "archive", srcs = [":src_file"], ) diff --git a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/BUILD.bazel b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/BUILD.bazel new file mode 100644 index 00000000..711bb905 --- /dev/null +++ b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/BUILD.bazel @@ -0,0 +1,23 @@ +load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") +load("//bzlrelease:defs.bzl", "release_archive") + +bzlformat_pkg(name = "bzlformat") + +release_archive( + name = "archive", + srcs = [ + "//bzlrelease:all_files", + "//bzlrelease/private:all_files", + "//bzlrelease/tools:all_files", + ], +) + +sh_test( + name = "archive_test", + srcs = ["archive_test.sh"], + data = [":archive"], + deps = [ + "@bazel_tools//tools/bash/runfiles", + "@cgrindel_bazel_starlib//shlib/lib:assertions", + ], +) diff --git a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh new file mode 100755 index 00000000..a3ccd7a0 --- /dev/null +++ b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# --- begin runfiles.bash initialization v2 --- +# Copy-pasted from the Bazel Bash runfiles library v2. +set -o nounset -o pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +# shellcheck disable=SC1090 +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -o errexit +# --- end runfiles.bash initialization v2 --- + +# MARK - Locate Deps + +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +source "${assertions_sh}" + +archive_tar_gz_location=cgrindel_bazel_starlib/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive.tar.gz +archive_tar_gz="$(rlocation "${archive_tar_gz_location}")" || \ + (echo >&2 "Failed to locate ${archive_tar_gz_location}" && exit 1) + +# MARK - Test + +contents="$(tar -tf "${archive_tar_gz}")" +assert_match "bzlrelease/" "${contents}" +assert_match "bzlrelease/private/" "${contents}" +assert_match "bzlrelease/tools/" "${contents}" diff --git a/updatesrc/BUILD.bazel b/updatesrc/BUILD.bazel index 380528c2..937a8048 100644 --- a/updatesrc/BUILD.bazel +++ b/updatesrc/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//visibility:public"]) @@ -30,10 +29,3 @@ filegroup( srcs = glob(["*"]), visibility = ["//:__subpackages__"], ) - -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) diff --git a/updatesrc/private/BUILD.bazel b/updatesrc/private/BUILD.bazel index c1598f3f..23b76a96 100644 --- a/updatesrc/private/BUILD.bazel +++ b/updatesrc/private/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("//bzlformat:defs.bzl", "bzlformat_pkg") package(default_visibility = ["//updatesrc:__subpackages__"]) @@ -34,13 +33,6 @@ filegroup( visibility = ["//:__subpackages__"], ) -pkg_files( - name = "release_files", - srcs = [":all_files"], - prefix = package_name(), - visibility = ["//:__subpackages__"], -) - bzl_library( name = "providers", srcs = ["providers.bzl"],