Skip to content

Improve automated releasing#78

Merged
MusicalNinjaDad merged 25 commits into
mainfrom
releasing
Oct 31, 2025
Merged

Improve automated releasing#78
MusicalNinjaDad merged 25 commits into
mainfrom
releasing

Conversation

@MusicalNinjaDad

@MusicalNinjaDad MusicalNinjaDad commented Oct 31, 2025

Copy link
Copy Markdown
Owner

Summary by Sourcery

Automate semantic version extraction and validation in the release pipeline, enforce changelog updates, update version to 0.3.1, and remove the old auto-release workflow

Enhancements:

  • Add a version job to the release workflow to derive semantic versioning from version.go or Git tags, validate tag consistency, and determine whether to release
  • Refactor the release job to depend on version outputs, adjust permissions, and tag Docker images and GitHub releases using the computed semantic version
  • Enhance the pre-commit changelog checker to auto-insert a templated entry for new versions and enforce manual updates, and add a go:generate hook in version.go

Chores:

  • Bump project version to 0.3.1
  • Remove deprecated auto-release workflow

@sourcery-ai

sourcery-ai Bot commented Oct 31, 2025

Copy link
Copy Markdown

Reviewer's Guide

Restructure CI workflows to decouple version detection from release steps, enforce version/tag consistency, refine Docker build metadata, automate changelog templating, and bump package version

Class diagram for version.go changes

classDiagram
  class Snaggle {
    +const Version : string
  }
Loading

Flow diagram for automated changelog templating

flowchart TD
  A["Run check_changelog.sh"] --> B["Extract version from version.go"]
  B --> C["Check for changelog entry"]
  C -->|Entry missing| D["Insert template entry for version"]
  D --> E["Exit with error"]
  C -->|Entry present and AUTOGENERATED| F["Prompt user to update changelog"]
  F --> E
  C -->|Entry present and updated| G["Continue"]
Loading

File-Level Changes

Change Details Files
Overhaul release.yml to automate versioning and gating
  • Add version job with tag_check, version_go, version_conflict, release_me, set_version, and create_tag steps
  • Output semver and release_me flags for downstream gating
  • Update release job to depend on version job and conditionally run on release_me
  • Adjust job permissions to write and streamline checkout usage
.github/workflows/release.yml
Refine Docker build and metadata configuration
  • Switch devcontainer build to use explicit Dockerfile path
  • Configure metadata-action to tag images using computed semver
  • Simplify build-push context and outputs settings
.github/workflows/release.yml
Improve changelog automation script
  • Auto-insert a templated changelog entry when missing
  • Abort CI on autogenerated markers to enforce manual updates
  • Enhance error messages for missing or stale entries
.pre-commit/check_changelog.sh
Add go:generate directive and bump version
  • Include generate directive in version.go for changelog checks
  • Update Version constant from 0.3.0 to 0.3.1
version.go
Remove obsolete auto-release workflow
  • Delete deprecated auto-release workflow file
.github/workflows/auto-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 there - I've reviewed your changes - here's some feedback:

  • The startsWith expressions in the version job are reversed – it should be startsWith(github.ref, 'refs/tags/v') instead of startsWith('/refs/tags/v', github.ref) to correctly detect tagged refs.
  • Verify that the //go:generate directive reliably invokes the check_changelog.sh script (e.g. prefix with bash and ensure the script is executable) so that go generate runs as expected.
  • Double-check that removing the explicit context input from the Build and push Docker image step still uses the intended build context and doesn’t pull in unintended files.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The startsWith expressions in the version job are reversed – it should be startsWith(github.ref, 'refs/tags/v') instead of startsWith('/refs/tags/v', github.ref) to correctly detect tagged refs.
- Verify that the //go:generate directive reliably invokes the check_changelog.sh script (e.g. prefix with bash and ensure the script is executable) so that go generate runs as expected.
- Double-check that removing the explicit context input from the Build and push Docker image step still uses the intended build context and doesn’t pull in unintended files.

## Individual Comments

### Comment 1
<location> `.github/workflows/release.yml:13` </location>
<code_context>
-  docker:
+
+  version:
+    if: ${{ github.ref == 'refs/heads/main' || startsWith( '/refs/tags/v', github.ref) }}
+    runs-on: ubuntu-latest
+
</code_context>

<issue_to_address>
**issue (bug_risk):** The startsWith function uses a leading slash in the ref argument, which may not match actual tag refs.

Remove the leading slash from the argument in startsWith to match the actual tag ref format and avoid unexpected failures.
</issue_to_address>

### Comment 2
<location> `.github/workflows/release.yml:26-28` </location>
<code_context>
+    steps:
+      - uses: actions/checkout@v5
+
+      - id: tag_check
+        if: ${{ startsWith( '/refs/tags/v', github.ref) }}
+        run: |
+          main_sha=$(git show-ref --verify refs/heads/main | awk '{ print $1 }')
+          if [[ ${{ github.sha }} != $main_sha ]]; then
</code_context>

<issue_to_address>
**issue (bug_risk):** The tag_check step uses '/refs/tags/v' in startsWith, which may not match the actual ref format.

The ref should be 'refs/tags/v' without the leading slash. Please update the string to ensure correct matching.
</issue_to_address>

### Comment 3
<location> `.github/workflows/release.yml:58-60` </location>
<code_context>
+        if: ${{ steps.release_me.outputs.release_me == 'true' }}
+        run: echo "SEMVER=${{ steps.tag_check.outputs.TAG || steps.version_go.outputs.VERSION_GO }}" >> "$GITHUB_OUTPUT"
+
+      - id: create_tag
+        if: ${{ steps.tag_check.outcome == 'skipped' && steps.release_me.outputs.release_me == 'true' }}
+        run: git tag ${{ steps.set_version.outputs.semver }} && git push --tags
+
+  release:
</code_context>

<issue_to_address>
**suggestion:** Directly pushing tags from the workflow may cause issues if the runner does not have the correct permissions or if tags already exist.

Add error handling for cases where the tag already exists or push permissions are missing to prevent workflow failures and ensure consistent state.

```suggestion
      - id: create_tag
        if: ${{ steps.tag_check.outcome == 'skipped' && steps.release_me.outputs.release_me == 'true' }}
        run: |
          TAG="${{ steps.set_version.outputs.semver }}"
          if git rev-parse "$TAG" >/dev/null 2>&1; then
            echo "::warning title=Tag exists::Tag $TAG already exists. Skipping tag creation."
          else
            git tag "$TAG" || { echo "::error title=Tag creation failed::Failed to create tag $TAG"; exit 1; }
            git push --tags || { echo "::error title=Tag push failed::Failed to push tags. Check permissions."; exit 1; }
          fi
```
</issue_to_address>

### Comment 4
<location> `.github/workflows/release.yml:91-100` </location>
<code_context>
+    permissions:
+      contents: write
+
+    outputs:
+      semver: ${{ steps.set_version.outputs.semver }}
+      release_me: ${{ steps.release_me.outputs.release_me }}
</code_context>

<issue_to_address>
**suggestion:** The outputs field in docker/build-push-action is set to local, which may not be necessary for a release workflow.

If local output is unused, removing it can reduce disk usage and speed up the workflow.

Suggested implementation:

```
      - uses: actions/checkout@v5

      # Remove any outputs: local from docker/build-push-action steps below (if present)
      # Example:
      # - name: Build and push Docker image
      #   uses: docker/build-push-action@v5
      #   with:
      #     context: .
      #     push: true
      #     tags: ${{ steps.set_version.outputs.semver }}
      #     # outputs: type=local,dest=./output  <-- REMOVE THIS LINE IF PRESENT

      - id: tag_check
        if: ${{ startsWith( '/refs/tags/v', github.ref) }}
        run: |
          main_sha=$(git show-ref --verify refs/heads/main | awk '{ print $1 }')
          if [[ ${{ github.sha }} != $main_sha ]]; then
            echo "::error title=Not main::Automated releasing is only possible for the head commit on main"

```

If there are any steps using `docker/build-push-action` with an `outputs: type=local,...` field elsewhere in the workflow, remove that field entirely. If you have multiple build steps, repeat this removal for each one. If you need to keep other output types (e.g., `type=registry`), only remove the `type=local` output.
</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/release.yml Outdated
Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml
@codecov

codecov Bot commented Oct 31, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.02%. Comparing base (0809630) to head (a2c22bd).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #78   +/-   ##
=======================================
  Coverage   74.02%   74.02%           
=======================================
  Files          11       11           
  Lines         566      566           
=======================================
  Hits          419      419           
  Misses        104      104           
  Partials       43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MusicalNinjaDad MusicalNinjaDad enabled auto-merge (squash) October 31, 2025 14:16
@MusicalNinjaDad MusicalNinjaDad merged commit 61626b7 into main Oct 31, 2025
13 checks passed
@MusicalNinjaDad MusicalNinjaDad deleted the releasing branch October 31, 2025 14:18
@MusicalNinjaDad MusicalNinjaDad linked an issue Oct 31, 2025 that may be closed by this pull request
4 tasks
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.

Automated releasing

1 participant