Skip to content

Commit c7b7c84

Browse files
committed
ci: update release workflow to improve version check and changelog generation
1 parent 71d9c50 commit c7b7c84

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,53 @@ on:
55
tags:
66
- "v*"
77

8+
permissions:
9+
contents: write
10+
811
jobs:
9-
publish:
12+
release:
1013
runs-on: ubuntu-latest
11-
environment:
12-
name: pypi
13-
url: https://pypi.org/p/shellflow
14-
permissions:
15-
contents: read
16-
id-token: write
17-
1814
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@v5
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
2119

22-
- name: Set up uv
23-
uses: astral-sh/setup-uv@v7
20+
- name: Setup uv
21+
uses: astral-sh/setup-uv@v5
2422
with:
2523
python-version: "3.12"
26-
enable-cache: true
27-
cache-dependency-glob: |
28-
pyproject.toml
29-
uv.lock
24+
25+
- name: Get version from tag
26+
id: tag_version
27+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
28+
29+
- name: Check pyproject.toml version
30+
run: |
31+
FILE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
32+
33+
echo "pyproject.toml version: $FILE_VERSION"
34+
echo "Tag version: ${{ env.VERSION }}"
35+
36+
if [ "$FILE_VERSION" != "${{ env.VERSION }}" ]; then
37+
echo "Error: pyproject.toml version ($FILE_VERSION) does not match tag version (${{ env.VERSION }})"
38+
exit 1
39+
fi
40+
41+
- name: Generate Changelog
42+
uses: orhun/git-cliff-action@v4
43+
id: git-cliff
44+
with:
45+
config: cliff.toml
46+
args: --verbose --latest --strip header
47+
env:
48+
OUTPUT: CHANGELOG.md
49+
50+
- name: Create GitHub Release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
body: ${{ steps.git-cliff.outputs.content }}
54+
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
3055

3156
- name: Install dependencies
3257
run: uv sync --all-groups
@@ -39,8 +64,10 @@ jobs:
3964
uv run pytest -q
4065
uv run behave features
4166
42-
- name: Build distributions
67+
- name: Build Package
4368
run: uv build
4469

4570
- name: Publish to PyPI
71+
env:
72+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
4673
run: uv publish

0 commit comments

Comments
 (0)