Skip to content

feat(packaging): add the shared nfpm action - #12

Closed
kduret wants to merge 6 commits into
mainfrom
MON-216366-packaging-nfpm
Closed

kduret wants to merge 6 commits into
mainfrom
MON-216366-packaging-nfpm

Conversation

@kduret

@kduret kduret commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Second action of the packaging package: packaging/nfpm, the shared version of the local package-nfpm / package actions (6 repositories, 15 variants once their maintained branches are counted). It goes in the same packaging 1.0.0 release as parse-distrib.

  • Builds one rpm or deb per nfpm configuration matching a pattern, caches the packages and optionally uploads them as an artifact.
  • It relies on what nfpm does itself instead of editing the configurations with sed: configurations read ${COMMIT_HASH} and their other values as variables (with expand: true on the contents entries using one in a path), the key file variable decides the signature, and --target writes the packages in the working directory.
  • The one thing written in a configuration is @APACHE_USER@ / @APACHE_GROUP@: nfpm does not read the owner of a file from the environment.
  • Inputs beyond the obvious ones: deb_release, deb_copyright and allow_unsigned. What a single repository needs stays in its workflows; the README lists, per repository, the inputs and the changes its switch needs.

The switch of a repository therefore changes its configurations too (@COMMIT_HASH@ to ${COMMIT_HASH}, and for a few @luaver@ or @PHP_MIN_VERSION@ to variables), in the same pull request as its workflows.

Behavior changes a reviewer cannot guess from the diff:

  • The signing key file is written outside the workspace and removed when the step ends; the local copies left key.gpg in the workspace.
  • An rpm without a signing key fails the step, with a clear message; allow_unsigned: "true" builds it unsigned instead, which is what centreon does today. The key is only written for an rpm build.
  • nfpm runs in the directory of the configuration, as in the Centreon repositories: relative paths of a configuration start there.
  • An @UPPERCASE@ placeholder left in a configuration fails the step in every repository; centreon-agent had no such check.
  • package_extension and stability are no longer inputs. NEXT_MAJOR_VERSION needs no branch-specific code: six months later before 26.10, the next month since.
  • Every deb takes the same distribution suffix. centreon-stream-connector-scripts used its own: its debs become <release>+deb12u1 instead of <release>~bookworm, which Debian sorts as newer for the same release.
  • The packages are cached with actions/cache/save v6.1.0; the callers restore them with older versions of the action.

Equivalence with the local copies:

  • Each of the 15 variants (develop, dev-26.10.x, dev-25.10.x, dev-24.10.x of centreon, centreon-collect, centreon-modules; develop of centreon-plugins, centreon-stream-connector-scripts, centreon-agent) was run next to this script with a stand-in of nfpm, on 7 distributions, 4 stabilities and several versions, the configurations of the shared side being written the new way.
  • 1218 cases, 62994 values compared (the variables given to nfpm, the configurations once their variables are resolved, the files next to them, the signing key of the rpm builds, the packages): no difference, apart from centreon-stream-connector-scripts: its new LUA_VERSION variable, and the suffix of its debs, changed on purpose.
  • Checked with nfpm 2.43.4: description and contents paths with expand: true are expanded, the owner of a file is not, empty key variables build an unsigned rpm, and a passphrase-protected key gives an rpm carrying RSA and PGP signatures.

Tests and checks:

  • 28 bats tests on the script.
  • lint builds a real, unsigned package with nfpm 2.43.4 inside Debian and AlmaLinux containers, cache step included.

Not covered here, to check when the callers switch:

  • A build signed with the real key, the artifact upload, and the restore of the cache by the delivery jobs.
  • Container jobs on the self-hosted runners.

Fixes: MON-216366

Builds rpm or deb packages from nfpm configurations, caches them and
optionally uploads them. What the local copies of the product repositories
did each on their own is an input.
@kduret kduret added enhancement New feature or request gha labels Nov 27, 2026
The package extension, the version cadence, the extra variables and the
per-distribution variable files leave the action: the first two are known
from its other inputs, the last two belong to the calling workflows.
The files next to a configuration are left to the calling workflow, and a
deb takes its release from deb_release instead of a stability rule.
The configurations read the commit hash and their other values as nfpm
variables, an empty key file variable skips the signature, and nfpm writes
the packages in the working directory itself.
An unsigned rpm is built only when allow_unsigned asks for it, and the key
is no longer written for a deb build.
@kduret

kduret commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #13: same change on a branch with a single commit.

@kduret kduret closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gha

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant