@@ -24,58 +24,83 @@ jobs:
2424 python -m pip install --upgrade pip
2525 python -m pip install --upgrade setuptools wheel build twine
2626
27- - name : Extract issue number
27+ - name : Clean dist directory
28+ run : |
29+ if (Test-Path -Path dist) { Remove-Item dist -Recurse -Force }
30+
31+ - name : Extract issue number and suffix
2832 id : issue
2933 if : startsWith(github.ref, 'refs/heads/')
3034 run : |
31- $ISSUE_NUMBER = git log -1 --pretty=%B | Select-String -Pattern '#(\d+)' | ForEach-Object { $_.Matches.Groups[1].Value }
32- if (-not $ISSUE_NUMBER) { $ISSUE_NUMBER = "dev" }
33- echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $env:GITHUB_ENV
34- echo "issue_number=$ISSUE_NUMBER" >> $env:GITHUB_OUTPUT
35+ # Look for #<number> in commit message
36+ $match = git log -1 --pretty=%B | Select-String -Pattern '#(\d+)'
37+ if ($match) {
38+ $num = $match.Matches.Groups[1].Value
39+ $suffix = "rc$num"
40+ } else {
41+ # No issue number => development build
42+ $suffix = 'dev0'
43+ }
44+ echo "SUFFIX=$suffix" >> $env:GITHUB_ENV
45+ echo "suffix=$suffix" >> $env:GITHUB_OUTPUT
3546
3647 - name : Extract version from pyproject.toml
3748 id : version
3849 run : |
39- $VERSION = ( Get-Content pyproject.toml | Select-String -Pattern 'version = "(.*)"').Matches.Groups[1].Value
40- $VERSION = $VERSION -replace '^v', '' # Remove 'v' prefix if present
50+ $verLine = Get-Content pyproject.toml | Select-String -Pattern 'version = "(.*)"'
51+ $VERSION = $verLine.Matches.Groups[1].Value -replace '^v', ''
4152 echo "VERSION=$VERSION" >> $env:GITHUB_ENV
4253 echo "version=$VERSION" >> $env:GITHUB_OUTPUT
43-
44- # For tags, extract the tag version
45- if ("${{ github.ref }}".StartsWith("refs/tags/")) {
46- $TAG_VERSION = "${{ github.ref }}".Substring(10) # Remove 'refs/tags/' prefix
47- $TAG_VERSION = $TAG_VERSION -replace '^v', '' # Remove 'v' prefix if present
54+ if ("${{ github.ref }}".StartsWith('refs/tags/')) {
55+ $TAG_VERSION = "${{ github.ref }}".Substring(10) -replace '^v', ''
4856 echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV
4957 }
5058
5159 - name : Build package
5260 run : |
5361 python -m build
5462
63+ - name : Check distributions
64+ run : |
65+ twine check dist/*
66+
5567 - name : Publish to Test PyPI (branch push)
5668 if : startsWith(github.ref, 'refs/heads/')
5769 env :
5870 TWINE_USERNAME : __token__
5971 TWINE_PASSWORD : ${{ secrets.TEST_PYPI }}
72+ SUFFIX : ${{ env.SUFFIX }}
6073 run : |
61- # Rename dist files to include RC and issue number
62- Get-ChildItem -Path dist -Filter "*.whl" | ForEach-Object {
63- $newName = $_.Name -replace "(mqpy-\d+\.\d+\.\d+)-", "`$1.rc${{ steps.issue.outputs.issue_number }}-"
64- Rename-Item -Path $_.FullName -NewName $newName
74+ # Rename wheel files to include suffix
75+ Get-ChildItem dist/*.whl | ForEach-Object {
76+ Write-Host "Original wheel: $_"
77+ $newName = $_.Name -replace '^(mqpy-\d+\.\d+\.\d+)-', '$1.' + $env:SUFFIX + '-'
78+ Write-Host "Renaming to: $newName"
79+ Rename-Item $_.FullName $newName
6580 }
66- Get-ChildItem -Path dist -Filter "*.tar.gz" | ForEach-Object {
67- $newName = $_.Name -replace "(mqpy-\d+\.\d+\.\d+)", "`$1.rc${{ steps.issue.outputs.issue_number }}"
68- Rename-Item -Path $_.FullName -NewName $newName
81+ # Rename source tarballs
82+ Get-ChildItem dist/*.tar.gz | ForEach-Object {
83+ Write-Host "Original tarball: $_"
84+ $newName = $_.Name -replace '^(mqpy-\d+\.\d+\.\d+)', '$1.' + $env:SUFFIX
85+ Write-Host "Renaming to: $newName"
86+ Rename-Item $_.FullName $newName
6987 }
70- twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*
88+
89+ Write-Host "Files ready for upload:"
90+ Get-ChildItem dist/* | ForEach-Object { Write-Host " $_" }
91+
92+ # Upload with verbose output for debugging
93+ twine upload --skip-existing --verbose --repository-url https://test.pypi.org/legacy/ dist/*
7194
7295 - name : Publish to PyPI (new tag)
7396 if : startsWith(github.ref, 'refs/tags/')
7497 env :
7598 TWINE_USERNAME : __token__
7699 TWINE_PASSWORD : ${{ secrets.PYPI_TOKEN }}
77100 run : |
78- twine upload dist/*
101+ Write-Host "Files to upload to PyPI:"
102+ Get-ChildItem dist/* | ForEach-Object { Write-Host " $_" }
103+ twine upload --verbose dist/*
79104
80105 - name : Create Step Summary
81106 run : |
@@ -114,7 +139,7 @@ jobs:
114139 This is a release candidate version published to Test PyPI.
115140
116141 ```
117- pip install mqpy==${{ env.VERSION }}.rc ${{ env.ISSUE_NUMBER }} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
142+ pip install mqpy==${{ env.VERSION }}.${{ env.SUFFIX }} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
118143 ```
119144 "@
120145 })
0 commit comments