Improve automated releasing#78
Merged
Merged
Conversation
Reviewer's GuideRestructure 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 changesclassDiagram
class Snaggle {
+const Version : string
}
Flow diagram for automated changelog templatingflowchart 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"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Closed
4 tasks
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.
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:
Chores: