Skip to content

Commit cb6364d

Browse files
authored
Merge pull request #44 from metagit-ai/zloeber/fix_broke_release
fix: broken release loop
2 parents 6cf483b + f52c011 commit cb6364d

3 files changed

Lines changed: 32 additions & 34 deletions

File tree

.github/workflows/release.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
PROJECT_NAME: metagit-cli
99

1010
concurrency:
11-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
group: ${{ github.workflow }}-${{ github.ref }}
1212
cancel-in-progress: true
1313

1414
permissions:
@@ -93,18 +93,4 @@ jobs:
9393
- name: Publish
9494
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
9595

96-
create-release:
97-
name: Create GitHub Release
98-
permissions:
99-
contents: write
100-
runs-on: ubuntu-latest
101-
needs: publish-to-pypi
102-
if: github.ref_type == 'tag'
103-
steps:
104-
- name: Create Release
105-
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
106-
with:
107-
files: dist/*
108-
make_latest: true
109-
generate_release_notes: true
11096

.github/workflows/semantic-release.yaml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- main
8+
paths-ignore:
9+
- CHANGELOG.md
810
workflow_dispatch:
911

1012
env:
@@ -84,47 +86,53 @@ jobs:
8486
MINOR=${MINOR:-0}
8587
PATCH=${PATCH:-0}
8688
89+
SHOULD_RELEASE=false
8790
if [[ $MAJOR_BUMP -eq 1 ]]; then
8891
MAJOR=$((MAJOR + 1))
8992
MINOR=0
9093
PATCH=0
94+
SHOULD_RELEASE=true
9195
elif [[ $MINOR_BUMP -eq 1 ]]; then
9296
MINOR=$((MINOR + 1))
9397
PATCH=0
94-
elif [[ $PATCH_BUMP -eq 1 ]] || git rev-parse "${{ steps.prev_tag.outputs.tag }}" >/dev/null 2>&1 && [[ "$PREV_TAG" != "0.0.0" ]]; then
98+
SHOULD_RELEASE=true
99+
elif [[ $PATCH_BUMP -eq 1 ]]; then
95100
PATCH=$((PATCH + 1))
96-
else
97-
if [[ "$PREV_TAG" == "0.0.0" ]] && [[ $PATCH_BUMP -eq 0 ]] && [[ $MINOR_BUMP -eq 0 ]] && [[ $MAJOR_BUMP -eq 0 ]]; then
98-
PATCH=1
99-
fi
101+
SHOULD_RELEASE=true
100102
fi
101103
102104
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
103105
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
106+
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
104107
echo "New version: $NEW_VERSION"
108+
echo "Should release: $SHOULD_RELEASE"
105109
106110
- name: Check if tag already exists
107111
id: check_tag
112+
if: steps.version.outputs.should_release == 'true'
108113
run: |
109-
if git rev-parse "refs/tags/${{ steps.version.outputs.new_version }}" >/dev/null 2>&1; then
114+
RELEASE_TAG="v${{ steps.version.outputs.new_version }}"
115+
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
116+
if git rev-parse "refs/tags/$RELEASE_TAG" >/dev/null 2>&1; then
110117
echo "tag_exists=true" >> $GITHUB_OUTPUT
111-
echo "Tag ${{ steps.version.outputs.new_version }} already exists"
118+
echo "Tag $RELEASE_TAG already exists"
112119
else
113120
echo "tag_exists=false" >> $GITHUB_OUTPUT
114121
fi
115122
116123
- name: Install uv
117-
if: steps.check_tag.outputs.tag_exists == 'false'
124+
if: steps.version.outputs.should_release == 'true' && steps.check_tag.outputs.tag_exists == 'false'
118125
run: |
119126
curl -LsSf https://astral.sh/uv/install.sh | sh
120127
echo "$HOME/.local/bin" >> $GITHUB_PATH
121128
122129
- name: Promote changelog and write release notes
123-
if: steps.check_tag.outputs.tag_exists == 'false'
130+
if: steps.version.outputs.should_release == 'true' && steps.check_tag.outputs.tag_exists == 'false'
124131
id: changelog
125132
run: |
126133
PREV_TAG=${{ steps.prev_tag.outputs.tag }}
127134
NEW_VERSION="${{ steps.version.outputs.new_version }}"
135+
NEW_TAG="${{ steps.check_tag.outputs.release_tag }}"
128136
RANGE=""
129137
if git rev-parse "$PREV_TAG" >/dev/null 2>&1; then
130138
RANGE="$PREV_TAG..HEAD"
@@ -139,33 +147,33 @@ jobs:
139147
140148
{
141149
echo ""
142-
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${NEW_VERSION}"
150+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${NEW_TAG}"
143151
} >> /tmp/release_body.md
144152
145153
- name: Commit promoted changelog
146-
if: steps.check_tag.outputs.tag_exists == 'false'
154+
if: steps.version.outputs.should_release == 'true' && steps.check_tag.outputs.tag_exists == 'false'
147155
run: |
148156
git add CHANGELOG.md
149157
if git diff --cached --quiet; then
150158
echo "No changelog promotion changes to commit"
151159
else
152-
git commit -m "chore: promote CHANGELOG for ${{ steps.version.outputs.new_version }}"
160+
git commit -m "chore: promote CHANGELOG for ${{ steps.check_tag.outputs.release_tag }}"
153161
git push origin main
154162
fi
155163
156164
- name: Create and push tag
157-
if: steps.check_tag.outputs.tag_exists == 'false'
165+
if: steps.version.outputs.should_release == 'true' && steps.check_tag.outputs.tag_exists == 'false'
158166
run: |
159-
git tag -a "${{ steps.version.outputs.new_version }}" -m "Release ${{ steps.version.outputs.new_version }}"
160-
git push origin "${{ steps.version.outputs.new_version }}"
161-
echo "Created and pushed tag: ${{ steps.version.outputs.new_version }}"
167+
git tag -a "${{ steps.check_tag.outputs.release_tag }}" -m "Release ${{ steps.check_tag.outputs.release_tag }}"
168+
git push origin "${{ steps.check_tag.outputs.release_tag }}"
169+
echo "Created and pushed tag: ${{ steps.check_tag.outputs.release_tag }}"
162170
163171
- name: Create GitHub Release
164-
if: steps.check_tag.outputs.tag_exists == 'false'
172+
if: steps.version.outputs.should_release == 'true' && steps.check_tag.outputs.tag_exists == 'false'
165173
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
166174
with:
167-
tag_name: ${{ steps.version.outputs.new_version }}
168-
name: Release ${{ steps.version.outputs.new_version }}
175+
tag_name: ${{ steps.check_tag.outputs.release_tag }}
176+
name: Release ${{ steps.check_tag.outputs.release_tag }}
169177
body_path: /tmp/release_body.md
170178
draft: false
171179
prerelease: false
@@ -174,4 +182,6 @@ jobs:
174182
run: |
175183
echo "Previous tag: ${{ steps.prev_tag.outputs.tag }}"
176184
echo "New version: ${{ steps.version.outputs.new_version }}"
185+
echo "Should release: ${{ steps.version.outputs.should_release }}"
186+
echo "Release tag: ${{ steps.check_tag.outputs.release_tag }}"
177187
echo "Tag exists: ${{ steps.check_tag.outputs.tag_exists }}"

docs/development.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ GitHub org/user listing is flat (no nested subgroups). GitLab groups honor `--re
8787
`.github/workflows/semantic-release.yaml` runs on merges to `main` and uses conventional commit prefixes to compute the next version.
8888

8989
- Promotes `## Unreleased` into a dated version section in `CHANGELOG.md`, commits to `main`, then tags.
90+
- Tags created by the workflow use the canonical `vX.Y.Z` format.
9091
- GitHub Release notes use the promoted changelog body (commit-log fallback only when `Unreleased` is empty).
92+
- Changelog-only commits do not retrigger semantic release, and no tag is created when there are no releasable `fix:`, `feat:`, or breaking-change commits since the previous tag.
9193
- Release automation is deterministic (no LLM). GitHub Copilot AI credits are not a free pipeline for custom workflows; they meter Copilot Chat/agents/review features instead.
9294

9395
- `fix:` -> patch release (`X.Y.Z+1`) **default for most updates**

0 commit comments

Comments
 (0)