56
56
echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV
57
57
}
58
58
59
- - name : Build package
59
+ - name : Create temporary pyproject.toml for test build
60
+ if : startsWith(github.ref, 'refs/heads/')
61
+ run : |
62
+ # Read the current pyproject.toml
63
+ $content = Get-Content pyproject.toml -Raw
64
+
65
+ # Get the current version
66
+ $version = "${{ env.VERSION }}"
67
+ $suffix = "${{ env.SUFFIX }}"
68
+
69
+ # Update the version with the suffix
70
+ $newVersion = "$version.$suffix"
71
+
72
+ # Replace the version in the content
73
+ $updatedContent = $content -replace 'version = "(.*?)"', "version = `"$newVersion`""
74
+
75
+ # Save to a temporary file
76
+ $updatedContent | Out-File -FilePath pyproject.toml.temp -Encoding utf8
77
+
78
+ # Show the changes
79
+ Write-Host "Original version: $version"
80
+ Write-Host "Updated version: $newVersion"
81
+
82
+ # Backup original and replace with temp version
83
+ Move-Item -Path pyproject.toml -Destination pyproject.toml.bak -Force
84
+ Move-Item -Path pyproject.toml.temp -Destination pyproject.toml -Force
85
+
86
+ - name : Build package for Test PyPI
87
+ if : startsWith(github.ref, 'refs/heads/')
88
+ run : |
89
+ python -m build
90
+
91
+ # After building, restore the original pyproject.toml
92
+ Move-Item -Path pyproject.toml.bak -Destination pyproject.toml -Force
93
+
94
+ - name : Build package for PyPI
95
+ if : startsWith(github.ref, 'refs/tags/')
60
96
run : |
61
97
python -m build
62
98
@@ -69,26 +105,7 @@ jobs:
69
105
env :
70
106
TWINE_USERNAME : __token__
71
107
TWINE_PASSWORD : ${{ secrets.TEST_PYPI }}
72
- SUFFIX : ${{ env.SUFFIX }}
73
108
run : |
74
- # Rename wheel files to include suffix
75
- Get-ChildItem dist/*.whl | ForEach-Object {
76
- Write-Host "Original wheel: $_"
77
- $suffix = $env:SUFFIX
78
- $newName = $_.Name -replace '^(mqpy-\d+\.\d+\.\d+)-', "`$1.$suffix-"
79
- Write-Host "Renaming to: $newName"
80
- Rename-Item $_.FullName $newName
81
- }
82
-
83
- # Rename source tarballs
84
- Get-ChildItem dist/*.tar.gz | ForEach-Object {
85
- Write-Host "Original tarball: $_"
86
- $suffix = $env:SUFFIX
87
- $newName = $_.Name -replace '^(mqpy-\d+\.\d+\.\d+)', "`$1.$suffix"
88
- Write-Host "Renaming to: $newName"
89
- Rename-Item $_.FullName $newName
90
- }
91
-
92
109
Write-Host "Files ready for upload:"
93
110
Get-ChildItem dist/* | ForEach-Object { Write-Host " $_" }
94
111
@@ -107,6 +124,13 @@ jobs:
107
124
108
125
- name : Create Step Summary
109
126
run : |
127
+ # Set the display version based on the ref
128
+ if ("${{ github.ref }}".StartsWith("refs/tags/")) {
129
+ $displayVersion = "${{ env.TAG_VERSION }}"
130
+ } else {
131
+ $displayVersion = "${{ env.VERSION }}.${{ env.SUFFIX }}"
132
+ }
133
+
110
134
@"
111
135
# MQPy Package
112
136
@@ -142,7 +166,7 @@ jobs:
142
166
This is a release candidate version published to Test PyPI.
143
167
144
168
```
145
- pip install mqpy==${{ env.VERSION }}.${{ env.SUFFIX }} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
169
+ pip install mqpy==$displayVersion --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
146
170
```
147
171
"@
148
172
})
0 commit comments