@@ -24,58 +24,83 @@ jobs:
24
24
python -m pip install --upgrade pip
25
25
python -m pip install --upgrade setuptools wheel build twine
26
26
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
28
32
id : issue
29
33
if : startsWith(github.ref, 'refs/heads/')
30
34
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
35
46
36
47
- name : Extract version from pyproject.toml
37
48
id : version
38
49
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', ''
41
52
echo "VERSION=$VERSION" >> $env:GITHUB_ENV
42
53
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', ''
48
56
echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV
49
57
}
50
58
51
59
- name : Build package
52
60
run : |
53
61
python -m build
54
62
63
+ - name : Check distributions
64
+ run : |
65
+ twine check dist/*
66
+
55
67
- name : Publish to Test PyPI (branch push)
56
68
if : startsWith(github.ref, 'refs/heads/')
57
69
env :
58
70
TWINE_USERNAME : __token__
59
71
TWINE_PASSWORD : ${{ secrets.TEST_PYPI }}
72
+ SUFFIX : ${{ env.SUFFIX }}
60
73
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
65
80
}
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
69
87
}
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/*
71
94
72
95
- name : Publish to PyPI (new tag)
73
96
if : startsWith(github.ref, 'refs/tags/')
74
97
env :
75
98
TWINE_USERNAME : __token__
76
99
TWINE_PASSWORD : ${{ secrets.PYPI_TOKEN }}
77
100
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/*
79
104
80
105
- name : Create Step Summary
81
106
run : |
@@ -114,7 +139,7 @@ jobs:
114
139
This is a release candidate version published to Test PyPI.
115
140
116
141
```
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/
118
143
```
119
144
"@
120
145
})
0 commit comments