-
-
Notifications
You must be signed in to change notification settings - Fork 779
Packaging: Inject st2 version into rpm/deb packages (pants-plugins/release) #6321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It looks awesome and pretty useful on the first glance. I will take the time for a full review on the weekend. |
winem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
dd86e54 to
1370f97
Compare
|
CircleCI builds are broken thanks to a new release of setuptools (v78) that removes support for deprecated keys in I'm working on fixing this by add a constraint to the wheels that are inadvertently (in st2-packages CI) pulling in this too-new version of setuptools. |
This PR is working towards doing packaging via pantsbuild. Eventually, I hope to archive and stop using st2-packages.git.
This PR enables the
nfpmbackend in pants and updatespants-plugins/releaseso that it can inject the version number into the rpm/deb similar to how that plugin injects the version in python wheels that pants builds. To keep this PR focused onpants-plugins/release, it does not add any BUILD metadata likenfpm_deb_packageornfpm_rpm_package. Adding the BUILD metadata, and using the changes introduced in this PR, will come in follow-up PRs.Relevant pants docs about nfpm:
nfpmsubsystemnfpm_deb_packagetargetversion_schemafieldversionfieldnfpm_rpm_packagetargetversion_schemafieldversionfieldInjectNfpmPackageFieldsRequestplugin hookRelevant pants docs about developing our
pants-plugins/release:Implemenation notes
It can be helpful to review each commit of this PR.
8290573: enable the nFPM backend in pants.
3e20568:
pants-plugins/releasewas introduced in Addpants-plugins/releaseto handle wheel metadata generation #5891 to help with injecting wheel metadata (like the version number) into the generated wheels. Since we already have the logic to get the version number, and we want to do the same for nfpm, I extracted that into a separate pants rule calledextract_version.st2/pants-plugins/release/rules.py
Lines 103 to 104 in 3e20568
6b508a2: Then I implemented an
InjectNfpmPackageFieldsRequestwith theinject_package_fieldsrule.st2/pants-plugins/release/rules.py
Lines 196 to 205 in 6b508a2
And, this registers our implementation with a
UnionRulehere:st2/pants-plugins/release/rules.py
Line 234 in 6b508a2
This is where this rule uses the
extract_versionrule introduced in the last commit:st2/pants-plugins/release/rules.py
Lines 208 to 215 in 6b508a2
Then the cleans up the version to match nfpm's expectations of
semverformatted versions:st2/pants-plugins/release/rules.py
Lines 217 to 221 in 6b508a2
Finally, the rule defines the fields that get injected in
nfpm_deb_packageandnfpm_rpm_packagetargets.st2/pants-plugins/release/rules.py
Lines 223 to 226 in 6b508a2
If the version extracted is
3.9.0dev, then the equivalent hard-coded BUILD metadata would look like:Note: A follow-up PR will inject
version_release, another nfpm package field. I did not include that in this PR, because it involves a script to retrieve the release number from packagecloud.