↓ Skip to main content

Signed commits for Renovate

·674 words·4 mins
Table of Contents
Renovate - This article is part of a series.
Part 4: This Article

Codeberg doesn’t sign merges made through the web UI, and Renovate commits unsigned under the identity of the token’s account. A signing subkey on my own GPG key plus an extra UID for Renovate solve this without a second account, and Codeberg then shows the commits as verified.

Starting point
#

A sample from forgejo/forgejo shows how the web UI behaves: the last 6 commits merged through the web are all not_signed_commit. Only the “fast-forward only” merge style keeps existing signatures, and it requires a branch based directly on main. Signed merges therefore happen locally, for example with the make target from part 3 .

Renovate’s own commits would otherwise need a bot account. Codeberg doesn’t support bot accounts, though; a second account would only be possible as a contributor.

Creating the subkey and UID
#

Renovate signs with a dedicated subkey on the existing primary key. In GPG, an email address belongs to a UID of the primary key, not to a subkey, and it has to be verified in the Codeberg account.

gpg --quick-add-uid <primary-fpr> "Renovate <renovate@example.com>"
gpg --quick-add-key <primary-fpr> rsa4096 sign 1y
gpg --quick-set-primary-uid <primary-fpr> "<own UID>"

Without the last line, the new UID becomes the primary one.

Exporting the subkey without a passphrase
#

Renovate doesn’t support a passphrase for GPG keys; gitPrivateKeyPassphrase only applies to SSH keys. The subkey is imported into a temporary GNUPGHOME and stored there without a passphrase:

gpg --armor --export-secret-subkeys '<subkey>!' > subkey.asc
export GNUPGHOME=$(mktemp -d)
gpg --import subkey.asc
gpg --list-secret-keys --with-keygrip

The output has to show sec# for the missing primary key and exactly one ssb [S]. gpg --passwd <subkey> fails there with “No secret key” because of the primary key stub, but talking to the agent directly works:

gpg-connect-agent "PASSWD <keygrip>" /bye

The new passphrase stays empty in the dialog. The Renovate docs expect the key on a single line, with \n instead of line breaks:

gpg --armor --export-secret-subkeys '<subkey>!' | awk '{printf "%s\\n", $0}'

This checks that signing works without a passphrase prompt:

echo test | gpg --batch --pinentry-mode error --local-user '<subkey>!' --sign > /dev/null

Afterwards, the temporary GNUPGHOME and subkey.asc can be deleted.

Codeberg and Woodpecker
#

The public key now contains the new UID and the subkey and has to be uploaded to Codeberg again. The exported line goes into the Woodpecker project of renovate-config as the secret renovate_git_private_key. The pipeline renovate-config/.woodpecker/renovate.yaml from part 1 gets two more variables:

steps:
  - name: renovate
    environment:
      RENOVATE_GIT_AUTHOR: "Renovate <renovate@example.com>"
      RENOVATE_GIT_PRIVATE_KEY:
        from_secret: renovate_git_private_key

The debug log then shows gitPrivateKey: GPG key detected and configuring commit signing. Codeberg displays Renovate’s commits as verified, with my own account as the signer.

SSH signing works as well and is simpler: Renovate supports a passphrase for it, the key needs no single-line format, and it doesn’t expire. GPG, on the other hand, allows a subkey on the existing key that can be revoked on its own.

Pitfalls
#

Without a ! after the key ID, gpg picks the newest signing subkey, and my own commits would suddenly be signed with the Renovate subkey. The local Git config needs the exclamation mark:

git config --global user.signingkey '<keyid>!'
echo test | gpg --local-user '<keyid>!' --sign | gpg --verify

In a dev container, the new value only applies after a restart, since VS Code copies ~/.gitconfig into the container at startup.

Once the subkey expires, Renovate can no longer sign. Extending it takes gpg --quick-set-expire and uploading the public key to Codeberg again; the secret stays the same.

After switching identities, existing Renovate branches carry a foreign email address and count as modified. Renovate doesn’t close them but appends " - abandoned" to the title; others show up in the dashboard under “PR Edited (Blocked)”. The rebase checkboxes in the dashboard bring the blocked ones back, while abandoned PRs and their branches have to be closed and deleted by hand.

Older commits can only be signed retroactively by rewriting history. Every commit from <base> onwards gets a new hash and requires a force push:

git rebase --rebase-merges --force-rebase --gpg-sign <base>

Found this helpful?
Consider supporting via:

Renovate - This article is part of a series.
Part 4: This Article