diff --git a/.github/workflows/publish_to_bcr.yml b/.github/workflows/publish_to_bcr.yml index a1688448..e6cf676b 100644 --- a/.github/workflows/publish_to_bcr.yml +++ b/.github/workflows/publish_to_bcr.yml @@ -24,7 +24,7 @@ jobs: uses: "bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.1.0" with: tag_name: "${{ inputs.version }}" - tag_prefix: "" + tag_prefix: "rules_pkg_providers-" registry_fork: "bazel-contrib/bazel-central-registry" draft: false secrets: diff --git a/MODULE.bazel b/MODULE.bazel index 2c7fef4c..3df122ed 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,10 +1,16 @@ module( name = "rules_pkg", version = "", # set by release pipeline from version.bzl. - compatibility_level = 1, repo_name = "rules_pkg", ) +local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository") + +local_repository( + name = "rules_pkg_providers", + path = "providers", +) + # Do not update to newer versions until you need a specific new feature. bazel_dep(name = "rules_license", version = "1.0.0") bazel_dep(name = "rules_python", version = "1.7.0") @@ -36,8 +42,6 @@ register_toolchains( dev_dependency = True, ) -local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository") - local_repository( name = "mappings_test_external_repo", path = "tests/mappings/external_repo", diff --git a/distro/BUILD b/distro/BUILD index aa0862fd..fb959b0d 100644 --- a/distro/BUILD +++ b/distro/BUILD @@ -99,6 +99,7 @@ py_test( ":distro", ":small_module", "//:standard_package", + "@rules_pkg_providers//:providers.bzl", ], env_inherit = ["PATH"], imports = [".."], diff --git a/distro/packaging_test.py b/distro/packaging_test.py index 74bef827..f8f92cc9 100644 --- a/distro/packaging_test.py +++ b/distro/packaging_test.py @@ -107,6 +107,7 @@ def _module_bazel_lines(self, local_path, sha256): 'module(name = "test_rules_pkg_packaging")', f'bazel_dep(name = "{self.source_repo}", version = "{self.version}", repo_name = "{self.dest_repo}")', f'archive_override(module_name = "{self.source_repo}", sha256 = "{sha256}", url = "file://{local_path}")', + f'bazel_dep(name = "rules_pkg_providers", version = "1.0.0")', ) def _workspace_lines(self, local_path, sha256): diff --git a/pkg/providers.bzl b/pkg/providers.bzl index 6d5fc271..39560c3a 100644 --- a/pkg/providers.bzl +++ b/pkg/providers.bzl @@ -14,78 +14,19 @@ """Packaging related providers.""" -PackageArtifactInfo = provider( - doc = """Metadata about a package artifact.""", - fields = { - "file": "File object for said artifact", - "file_name": "DEPRECATED (use fields of file instead): The file name of the artifact.", - "label": "Label which produced it", - }, +load( + "@rules_pkg_providers//:providers.bzl", + _PackageArtifactInfo = "PackageArtifactInfo", + _PackageDirsInfo = "PackageDirsInfo", + _PackageFilegroupInfo = "PackageFilegroupInfo", + _PackageFilesInfo = "PackageFilesInfo", + _PackageSymlinkInfo = "PackageSymlinkInfo", + _PackageVariablesInfo = "PackageVariablesInfo", ) -PackageVariablesInfo = provider( - doc = """Variables which may be substituted into package names and content.""", - fields = { - "values": "Dict of name/value pairs", - }, -) - -PackageFilesInfo = provider( - doc = """Provider representing the installation of one or more files to destination with attributes""", - fields = { - "attributes": """Attribute information, represented as a `dict`. - -Keys are strings representing attribute identifiers, values are -arbitrary data structures that represent the associated data. These are -most often strings, but are not explicitly defined. - -For known attributes and data type expectations, see the Common -Attributes documentation in the `rules_pkg` reference. - """, - - # This is a mapping of destinations to sources to allow for the same - # target to be installed to multiple locations within a package within a - # single provider. - "dest_src_map": """Map of file destinations to sources. - - Sources are represented by bazel `File` structures.""", - }, -) - -PackageDirsInfo = provider( - doc = """Provider representing the creation of one or more directories in a package""", - fields = { - "attributes": """See `attributes` in PackageFilesInfo.""", - "dirs": """string list: installed directory names""", - }, -) - -PackageSymlinkInfo = provider( - doc = """Provider representing the creation of a single symbolic link in a package""", - fields = { - "attributes": """See `attributes` in PackageFilesInfo.""", - "destination": """string: Filesystem link 'name'""", - "target": """string or Label: Filesystem link 'target'. - - TODO(nacl): Label sources not yet supported. - """, - }, -) - -# Grouping provider: the only one that needs to be consumed by packaging (or -# other) rules that materialize paths. -PackageFilegroupInfo = provider( - doc = """Provider representing a collection of related packaging providers, - - In the "fields" documentation, "origin" refers to the label identifying the - where the provider was originally defined. This can be used by packaging - rules to provide better diagnostics related to where packaging rules were - created. - - """, - fields = { - "pkg_files": "list of tuples of (PackageFilesInfo, origin)", - "pkg_dirs": "list of tuples of (PackageDirsInfo, origin)", - "pkg_symlinks": "list of tuples of (PackageSymlinkInfo, origin)", - }, -) +PackageArtifactInfo = _PackageArtifactInfo +PackageDirsInfo = _PackageDirsInfo +PackageFilegroupInfo = _PackageFilegroupInfo +PackageFilesInfo = _PackageFilesInfo +PackageSymlinkInfo = _PackageSymlinkInfo +PackageVariablesInfo = _PackageVariablesInfo diff --git a/providers/MODULE.bazel b/providers/MODULE.bazel index fa4467dc..753c356c 100644 --- a/providers/MODULE.bazel +++ b/providers/MODULE.bazel @@ -1,7 +1,6 @@ module( name = "rules_pkg_providers", version = "", # set by release pipeline from version.bzl. - compatibility_level = 1, repo_name = "rules_pkg_providers", )