Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 2b88cc8

Browse files
committed
new_version: v1.0.2
1 parent 27debb0 commit 2b88cc8

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,37 @@ jobs:
3131
id: extract
3232
run: |
3333
COMMIT_MSG="${{ github.event.head_commit.message }}"
34-
VERSION=$(printf "%s" "$COMMIT_MSG" | sed -n 's/.*new_version:[[:space:]]*\(v[0-9][0-9\.]*\).*/\1/p' | head -n1)
34+
VERSION=$(printf "%s" "$COMMIT_MSG" | sed -n 's/.*new_version:[[:space:]]*\(v\{0,1\}[0-9][0-9\.]*\).*/\1/p' | head -n1)
3535
if [ -z "$VERSION" ]; then
3636
echo "No version marker found in commit message." >&2
3737
exit 1
3838
fi
39+
# Normalize to always have leading 'v'
40+
VERSION="v${VERSION#v}"
3941
NOTES=$(printf "%s" "$COMMIT_MSG" | sed -n '1!p')
4042
RELEASE_BODY="$NOTES\n\nFull Changelog: https://github.com/${{ github.repository }}/commits/$VERSION"
4143
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4244
printf "release_body<<EOF\n%s\nEOF\n" "$RELEASE_BODY" >> "$GITHUB_OUTPUT"
45+
# Export for later normalization if needed
46+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
47+
printf "NOTES<<EOF\n%s\nEOF\n" "$NOTES" >> "$GITHUB_ENV"
4348
44-
- name: Verify package version matches commit version
49+
- name: Normalize version using package if mismatch
4550
run: |
4651
PKG_VERSION=$(python -c "import configparser; c=configparser.ConfigParser(); c.read('setup.cfg'); print(c['metadata']['version'])")
4752
COMMIT_VERSION="${{ steps.extract.outputs.version }}"
4853
STRIPPED="${COMMIT_VERSION#v}"
4954
echo "Package version: $PKG_VERSION"
5055
echo "Commit version: $STRIPPED"
5156
if [ "$PKG_VERSION" != "$STRIPPED" ]; then
52-
echo "Version mismatch: setup.cfg=$PKG_VERSION commit=$STRIPPED" >&2
53-
exit 1
57+
echo "Version mismatch: setup.cfg=$PKG_VERSION commit=$STRIPPED — overriding tag to v$PKG_VERSION"
58+
echo "VERSION=v$PKG_VERSION" >> "$GITHUB_ENV"
59+
else
60+
echo "VERSION=$COMMIT_VERSION" >> "$GITHUB_ENV"
5461
fi
62+
# Recompose release body using final VERSION
63+
RELEASE_BODY="$NOTES\n\nFull Changelog: https://github.com/${{ github.repository }}/commits/$VERSION"
64+
printf "RELEASE_BODY<<EOF\n%s\nEOF\n" "$RELEASE_BODY" >> "$GITHUB_ENV"
5565
5666
- name: Build package
5767
run: |
@@ -66,7 +76,7 @@ jobs:
6676
6777
- name: Create and push tag
6878
run: |
69-
VERSION="${{ steps.extract.outputs.version }}"
79+
VERSION="${{ env.VERSION }}"
7080
git config user.name "github-actions"
7181
git config user.email "github-actions@github.com"
7282
git tag -a "$VERSION" -m "Release $VERSION"
@@ -77,8 +87,8 @@ jobs:
7787
env:
7888
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7989
with:
80-
tag_name: ${{ steps.extract.outputs.version }}
81-
release_name: MainyDB ${{ steps.extract.outputs.version }}
82-
body: ${{ steps.extract.outputs.release_body }}
90+
tag_name: ${{ env.VERSION }}
91+
release_name: MainyDB ${{ env.VERSION }}
92+
body: ${{ env.RELEASE_BODY }}
8393
draft: false
8494
prerelease: false

0 commit comments

Comments
 (0)