Skip to content

Commit 313ced4

Browse files
committed
feat: update release workflow to handle created releases and add debug script for version checks
1 parent 6944d58 commit 313ced4

File tree

3 files changed

+88
-7
lines changed

3 files changed

+88
-7
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release and Publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
id-token: write
10+
11+
jobs:
12+
release-and-publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/[email protected]
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.x'
23+
24+
# Get current version
25+
- name: Get current version
26+
id: ver
27+
run: |
28+
cur=$(cat src/veedb/VERSION 2>/dev/null || echo "0.0.0")
29+
echo "current=$cur" >> "$GITHUB_OUTPUT"
30+
31+
# Bump patch version
32+
- name: Bump patch version
33+
id: bump
34+
run: |
35+
IFS='.' read -r MAJ MIN PAT <<< "${{ steps.ver.outputs.current }}"
36+
PAT=$((PAT + 1))
37+
NEW="$MAJ.$MIN.$PAT"
38+
echo "$NEW" > src/veedb/VERSION
39+
echo "new=$NEW" >> "$GITHUB_OUTPUT"
40+
41+
# Commit and tag
42+
- name: Commit and tag
43+
env:
44+
NEW_VERSION: ${{ steps.bump.outputs.new }}
45+
run: |
46+
git config user.name "github-actions"
47+
git config user.email "[email protected]"
48+
git add src/veedb/VERSION
49+
git commit -m "chore: bump version to v$NEW_VERSION [skip ci]" || true
50+
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
51+
git push origin HEAD
52+
git push origin "v$NEW_VERSION"
53+
54+
# Build package
55+
- name: Install build tools
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install build twine
59+
60+
- name: Build package
61+
run: python -m build
62+
63+
# Create GitHub Release
64+
- name: Create GitHub Release
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
tag_name: v${{ steps.bump.outputs.new }}
68+
name: Release v${{ steps.bump.outputs.new }}
69+
draft: false
70+
prerelease: false
71+
generate_release_notes: true
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
# Publish to PyPI
76+
- name: Publish to PyPI
77+
uses: pypa/gh-action-pypi-publish@release/v1
78+
with:
79+
user: __token__
80+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ on:
44
push:
55
branches: [main] # bump version & create Release
66
release:
7-
types: [published] # build & upload to PyPI
7+
types: [published, created] # build & upload to PyPI
8+
workflow_dispatch: # allow manual trigger
89

910
permissions:
1011
contents: write
@@ -78,22 +79,22 @@ jobs:
7879
echo "- Version bump only" > CHANGELOG_GH_ACTION.md
7980
fi
8081
81-
echo "body_path=CHANGELOG_GH_ACTION.md" >> "$GITHUB_OUTPUT"
82-
83-
# Create GitHub Release with the changelog as body
82+
echo "body_path=CHANGELOG_GH_ACTION.md" >> "$GITHUB_OUTPUT" # Create GitHub Release with the changelog as body
8483
- name: Create GitHub Release
85-
uses: softprops/action-gh-release@v2.3.2
84+
uses: softprops/action-gh-release@v2
8685
with:
8786
tag_name: v${{ steps.bump.outputs.new }}
8887
body_path: ${{ steps.changelog.outputs.body_path }}
88+
draft: false
89+
prerelease: false
8990
env:
9091
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9192

9293
# ────────────────────────────────────────
9394
# 2. Job B: build & publish when Release fires
9495
# ────────────────────────────────────────
9596
deploy:
96-
if: github.event_name == 'release'
97+
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'created')
9798
runs-on: ubuntu-latest
9899
environment: pypi
99100

src/veedb/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.3
1+
0.1.1

0 commit comments

Comments
 (0)