STAC-25500 Port the DEB signing and pre-release publishing lane to GitHub Actions - #455
Open
LouisParkin wants to merge 1 commit into
Open
STAC-25500 Port the DEB signing and pre-release publishing lane to GitHub Actions#455LouisParkin wants to merge 1 commit into
LouisParkin wants to merge 1 commit into
Conversation
…itHub Closes the last two GitLab jobs with no GitHub counterpart: sign_deb and pre_release_deb (.gitlab-ci-agent.yml lines 604 and 635). Security prerequisite, not cleanup ---------------------------------- sign_debian_package.sh called printenv unconditionally. On GitLab that dumped the GPG private key and its passphrase into the job log; stackstate-agent is a PUBLIC repo, so on GitHub that log is world-readable. It also left the exported private key in the checkout as gpg_private.key, where any later artifact upload would collect it. Both are removed before any signing secret is wired in. Key setup now happens in an ephemeral GNUPGHOME created with mktemp and mode 700, removed by an EXIT trap that also kills the gpg-agent so a preset passphrase cannot outlive the job on a reused runner. The passphrase reaches gpg through a mode-600 file inside that directory rather than argv. Fixes a latent signing bug -------------------------- The old preset step interpolated an unquoted command substitution into a single gpg-preset-passphrase call. A key exposes one keygrip per primary and subkey, so with a signing subkey the second keygrip was passed as a stray argument and never presetted, leaving signing able to block on a pinentry prompt no CI runner can answer. Each keygrip is now presetted individually. Verified against a throwaway key: two keygrips, both presetted. Shared setup ------------ sign_debian_package.sh and publish_package.sh need the same key in the same state but are separate processes, and on GitHub may be separate steps, so neither can rely on a keyring the other left behind. The setup moves into gpg_signing_setup.sh, sourced by both. gpg-preset-passphrase is auto-detected across /usr/lib/gnupg2, /usr/lib/gnupg, /usr/libexec and PATH, and the script fails loudly rather than silently skipping the preset when it is absent. Both scripts now fall back from CI_PROJECT_DIR to GITHUB_WORKSPACE, and publish_package.sh falls back from CI_COMMIT_REF_NAME to GITHUB_REF_NAME, so the apt codename stays the release branch exactly as it was on GitLab. Workflow -------- sign-and-publish-deb downloads both architecture artifacts and runs a single deb-s3 upload. GitLab fanned this out per architecture, so two jobs rewrote the same apt index concurrently; collecting both first removes that race. The install script is split in two. generate-install-script runs inv release.generate-install -t inside the build container, because the task collection imports python-gitlab and the GitHub and Datadog API helpers and only loads in the conda environment, and asserts the rendered script contains no None.s3.amazonaws.com from an unset bucket variable. publish-install-script then uploads it, so the container job never holds a credential. Both publishing jobs are gated on push and bound to the agent-pre-release environment, which carries the deployment branch rule, the signing secrets and the AWS role from STAC-25545. Pull requests cannot reach them. Validated: shellcheck -x clean on all three scripts; gpg_signing_setup exercised against a generated throwaway key covering explicit override, PATH auto-detection and the missing-binary failure path; actionlint clean apart from the pre-existing self-hosted runner-label notices; zizmor reports no findings. Blocked until the agent-pre-release environment, its four SIGNING_* secrets and AGENT_PRERELEASE_ROLE_ARN exist. Refs STAC-25546, STAC-25545 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the last two GitLab jobs on this repo with no GitHub counterpart:
sign_debandpre_release_deb(.gitlab-ci-agent.ymllines 604 and 635). Stacked on #454.Security prerequisite, not cleanup
sign_debian_package.shcalledprintenvunconditionally. On GitLab that dumped the GPG private key and its passphrase into the job log.stackstate-agentis a public repo, so on GitHub that log is world-readable. It also left the exported private key in the checkout asgpg_private.key, where any later artifact upload would collect it.Both are removed before any signing secret is wired in, as STAC-25500 requires. Key setup now happens in an ephemeral
GNUPGHOME(mktemp, mode 700) removed by anEXITtrap that also kills thegpg-agent, so a preset passphrase cannot outlive the job on a reused runner. The passphrase reaches gpg through a mode-600 file, never argv.Fixes a latent signing bug
The old preset step was:
A key exposes one keygrip per primary and subkey. Unquoted, that substitution expands to multiple words, so with a signing subkey the second keygrip became a stray argument and was never presetted — leaving signing able to block on a pinentry prompt no CI runner can answer. Each keygrip is now presetted individually.
Verified against a generated throwaway key: two keygrips, both presetted, passphrase delivered on stdin,
GNUPGHOMEremoved by the trap, nothing left in the workspace.Shared setup
The two scripts need the same key in the same state but are separate processes, and on GitHub may be separate steps, so neither can rely on a keyring the other left behind. The setup moves into
gpg_signing_setup.sh, sourced by both.gpg-preset-passphraseis auto-detected across/usr/lib/gnupg2,/usr/lib/gnupg,/usr/libexecandPATH(the path differs by distro and release), and it fails loudly rather than silently skipping the preset when absent.Both scripts fall back
CI_PROJECT_DIR→GITHUB_WORKSPACE, andpublish_package.shfalls backCI_COMMIT_REF_NAME→GITHUB_REF_NAME, so the apt codename stays the release branch exactly as on GitLab.Workflow
sign-and-publish-debdeb-s3 upload. GitLab fanned this out per arch, so two jobs rewrote the same apt index concurrently — collecting both first removes that race.generate-install-scriptinv release.generate-install -tinside the build container: the task collection importspython-gitlabplus the GitHub/Datadog API helpers and only loads in the conda env. Asserts the rendered script contains noNone.s3.amazonaws.comfrom an unset bucket variable —generate_installreads three bucket vars and silently rendersNonefor any that are missing.publish-install-scriptBoth publishing jobs are gated on
pushand bound to theagent-pre-releaseenvironment, which carries the deployment branch rule, the signing secrets and the AWS role. Pull requests cannot reach them.Blocked on
This lane cannot go green until these exist — the code is ready and reviewable now:
agent-pre-releasewith a deployment branch rule for the release branch.SIGNING_PUBLIC_KEY,SIGNING_PRIVATE_KEY,SIGNING_PRIVATE_PASSPHRASE,SIGNING_KEY_ID.AGENT_PRERELEASE_ROLE_ARN, from StackVista/terraform-infra#76 (STAC-25545).Validation
shellcheck -x— clean on all three scripts.gpg_signing_setupexercised against a real generated key: explicit override,PATHauto-detection, and the missing-binary failure path (exits 1 with a clear message).actionlint— clean apart from the pre-existing self-hostedrunner-labelnotices.zizmorv1.28.0 —No findings to report.needs:references resolve.https://stackstate.atlassian.net/browse/STAC-25500
Refs https://stackstate.atlassian.net/browse/STAC-25546 and https://stackstate.atlassian.net/browse/STAC-25545