diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e6eae0554c..658d519ffb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -79,7 +79,7 @@ Added to pants' use of PEX lockfiles. This is not a user-facing addition. #6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253 #6254 #6258 #6259 #6260 #6269 #6275 #6279 #6278 #6282 #6283 #6273 #6287 #6306 #6307 - #6311 #6314 #6315 #6317 #6319 #6312 #6320 #6321 #6323 + #6311 #6314 #6315 #6317 #6319 #6312 #6320 #6321 #6323 #6324 Contributed by @cognifloyd * Build of ST2 EL9 packages #6153 Contributed by @amanda11 diff --git a/pants-plugins/release/register.py b/pants-plugins/release/register.py index b3fa04132f..93a680a563 100644 --- a/pants-plugins/release/register.py +++ b/pants-plugins/release/register.py @@ -17,7 +17,11 @@ """ from release.rules import rules as release_rules +from release.target_types import rules as release_target_types_rules def rules(): - return release_rules() + return [ + *release_target_types_rules(), + *release_rules(), + ] diff --git a/pants-plugins/release/rules.py b/pants-plugins/release/rules.py index 71f3f46b6e..f2f86905f0 100644 --- a/pants-plugins/release/rules.py +++ b/pants-plugins/release/rules.py @@ -51,6 +51,7 @@ packagecloud_get_next_release, ) from .packagecloud_rules import rules as packagecloud_rules +from .target_types import DistroIDField REQUIRED_KWARGS = ( @@ -240,7 +241,7 @@ async def inject_package_fields( next_release = await packagecloud_get_next_release( PackageCloudNextReleaseRequest( nfpm_arch=target[NfpmArchField].value, - distro_id="", # TODO: add field for distro ID + distro_id=target[DistroIDField].value, package_name=target[NfpmPackageNameField].value, package_version=version, production=not is_dev, diff --git a/pants-plugins/release/target_types.py b/pants-plugins/release/target_types.py new file mode 100644 index 0000000000..ce5e481e8e --- /dev/null +++ b/pants-plugins/release/target_types.py @@ -0,0 +1,52 @@ +# Copyright 2025 The StackStorm Authors. +# +# 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. + +from __future__ import annotations + +from pants.backend.nfpm.target_types import NfpmDebPackage, NfpmRpmPackage +from pants.engine.target import StringField +from pants.util.strutil import help_text + + +class DistroIDField(StringField): + nfpm_alias = "" # Not an nFPM field + alias = "distro_id" + valid_choices = ( # officially supported (or planned future support) + # ubuntu + "focal", + "jammy", + "noble", + # el + "el8", + "el9", + ) + required = True + help = help_text( + """ + The package distribution and version. + + This is an internal StackStorm field used by pants-plugins/release. + The IDs are StackStorm-specific IDs that get translated into distribution + version. + These examples show how the distro_id gets translated into packagecloud values: + - distro_id "el8" is distro "el" with version "8"; + - distro_id "focal" is distro "ubuntu" with version "focal". + """ + ) + + +def rules(): + return [ + NfpmDebPackage.register_plugin_field(DistroIDField), + NfpmRpmPackage.register_plugin_field(DistroIDField), + ]