Skip to content

Commit b7ba358

Browse files
committed
fix: ensure workflows checkout exact tag for clean version detection
- Add ref: ${{ github.ref }} to checkout action to ensure we're on the exact tag - Add git state verification step to confirm we're on exact tag - Add setuptools-scm verification to display detected version in logs This fixes the issue where setuptools-scm was detecting 2.2.2.post1.dev0 instead of clean 2.2.2 because the checkout wasn't at the exact tag commit. With this fix, wheels will be built with clean version numbers (e.g., 2.2.2) instead of post-release dev versions (e.g., 2.2.2.post1.dev0).
1 parent 6a2755c commit b7ba358

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/workflows/publish_pypi.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- uses: actions/checkout@v3
2323
name: Check out
2424
with:
25+
ref: ${{ github.ref }} # Explicitly checkout the triggering ref (tag)
2526
fetch-depth: 0 # Fetch all history for setuptools-scm
2627
fetch-tags: true # Explicitly fetch tags
2728

@@ -37,6 +38,14 @@ jobs:
3738
with:
3839
python-version: '3.11'
3940

41+
- name: Verify git state
42+
run: |
43+
echo "Git ref: ${{ github.ref }}"
44+
echo "Git ref name: ${{ github.ref_name }}"
45+
git describe --tags --exact-match 2>/dev/null && echo "✅ On exact tag" || echo "⚠️ Not on exact tag"
46+
git describe --tags --long
47+
shell: bash
48+
4049
- name: Update version files
4150
run: |
4251
python -m pip install setuptools-scm
@@ -48,6 +57,9 @@ jobs:
4857
else
4958
python scripts/update_versions.py
5059
fi
60+
# Verify setuptools-scm version detection
61+
echo "setuptools-scm detects version:"
62+
python -m setuptools_scm
5163
shell: bash
5264

5365
- name: Install cibuildwheel
@@ -104,6 +116,7 @@ jobs:
104116
- uses: actions/checkout@v3
105117
name: Check out
106118
with:
119+
ref: ${{ github.ref }} # Explicitly checkout the triggering ref (tag)
107120
fetch-depth: 0 # Fetch all history for setuptools-scm
108121
fetch-tags: true # Explicitly fetch tags
109122

@@ -119,6 +132,14 @@ jobs:
119132
with:
120133
python-version: '3.11'
121134

135+
- name: Verify git state
136+
run: |
137+
echo "Git ref: ${{ github.ref }}"
138+
echo "Git ref name: ${{ github.ref_name }}"
139+
git describe --tags --exact-match 2>/dev/null && echo "✅ On exact tag" || echo "⚠️ Not on exact tag"
140+
git describe --tags --long
141+
shell: bash
142+
122143
- name: Update version files
123144
run: |
124145
python -m pip install setuptools-scm
@@ -130,6 +151,9 @@ jobs:
130151
else
131152
python scripts/update_versions.py
132153
fi
154+
# Verify setuptools-scm version detection
155+
echo "setuptools-scm detects version:"
156+
python -m setuptools_scm
133157
shell: bash
134158

135159
- name: Install cibuildwheel

0 commit comments

Comments
 (0)