Skip to content

fix: sign semantic-release commits#2380

Merged
jdobes merged 1 commit into
RedHatInsights:masterfrom
jdobes:fix/sign-semantic-release-commits
Jun 5, 2026
Merged

fix: sign semantic-release commits#2380
jdobes merged 1 commit into
RedHatInsights:masterfrom
jdobes:fix/sign-semantic-release-commits

Conversation

@jdobes

@jdobes jdobes commented Jun 5, 2026

Copy link
Copy Markdown
Member

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Build:

  • Configure semantic-release GitHub Actions workflow to use an SSH key for GPG commit and tag signing.

@sourcery-ai

sourcery-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Configures semantic-release workflow to sign commits and tags using an SSH GPG key stored in GitHub secrets.

Sequence diagram for semantic-release signed commits configuration

sequenceDiagram
    participant GitHubActionsRunner as GitHubActionsRunner
    participant GitConfig as git
    participant GitHubSecrets as GitHubSecrets
    participant SemanticRelease as semantic-release

    GitHubActionsRunner->>GitHubSecrets: read SEMANTIC_RELEASE_SIGNING_KEY
    GitHubActionsRunner->>GitConfig: git config gpg.format ssh
    GitHubActionsRunner->>GitConfig: git config user.signingkey ~/.ssh/signing_key
    GitHubActionsRunner->>GitConfig: git config commit.gpgSign true
    GitHubActionsRunner->>GitConfig: git config tag.gpgSign true
    GitHubActionsRunner->>SemanticRelease: run semantic-release
    SemanticRelease->>GitConfig: create signed commits and tags
Loading

File-Level Changes

Change Details Files
Enable SSH-based GPG signing for semantic-release commits and tags in the CI workflow.
  • Add a workflow step to create ~/.ssh/signing_key from the SEMANTIC_RELEASE_SIGNING_KEY secret with secure permissions
  • Configure git globally in the workflow to use SSH-based GPG (gpg.format ssh) and the created signing key
  • Enable automatic GPG signing for all commits and tags created during the workflow run
.github/workflows/semantic-release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider configuring commit signing at the repository level (e.g., git config user.signingkey ...) instead of using --global, so the runner’s global Git config isn’t modified in ways that could affect other jobs on the same runner.
  • It may be worth guarding the signing configuration step with a condition (e.g., checking that secrets.SEMANTIC_RELEASE_SIGNING_KEY is set) to avoid the workflow failing unexpectedly when the secret is not available in a given environment.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider configuring commit signing at the repository level (e.g., `git config user.signingkey ...`) instead of using `--global`, so the runner’s global Git config isn’t modified in ways that could affect other jobs on the same runner.
- It may be worth guarding the signing configuration step with a condition (e.g., checking that `secrets.SEMANTIC_RELEASE_SIGNING_KEY` is set) to avoid the workflow failing unexpectedly when the secret is not available in a given environment.

## Individual Comments

### Comment 1
<location path=".github/workflows/semantic-release.yml" line_range="30-35" />
<code_context>
         with:
           fetch-depth: 0
           persist-credentials: false # The auth token is persisted in the local git config. semantic-release picks this one instead of GH_TOKEN
+      - name: Configure SSH commit signing
+        env:
+          SIGNING_KEY: ${{ secrets.SEMANTIC_RELEASE_SIGNING_KEY }}
+        run: |
+          mkdir -p ~/.ssh
+          echo "$SIGNING_KEY" > ~/.ssh/signing_key
+          chmod 600 ~/.ssh/signing_key
+          git config --global gpg.format ssh
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against missing or empty SIGNING_KEY to avoid confusing runtime behavior.

If `SEMANTIC_RELEASE_SIGNING_KEY` is unset or empty, this step still writes an empty `signing_key` file, causing opaque signing failures later. Please add a guard (e.g., `test -n "$SIGNING_KEY" || { echo "SIGNING_KEY missing" >&2; exit 1; }`) so the workflow fails fast with a clear error when the secret is misconfigured.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/semantic-release.yml
@jdobes
jdobes merged commit 627cb4f into RedHatInsights:master Jun 5, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants