5656 echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV
5757 }
5858
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/')
6096 run : |
6197 python -m build
6298
@@ -69,26 +105,7 @@ jobs:
69105 env :
70106 TWINE_USERNAME : __token__
71107 TWINE_PASSWORD : ${{ secrets.TEST_PYPI }}
72- SUFFIX : ${{ env.SUFFIX }}
73108 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-
92109 Write-Host "Files ready for upload:"
93110 Get-ChildItem dist/* | ForEach-Object { Write-Host " $_" }
94111
@@ -107,6 +124,13 @@ jobs:
107124
108125 - name : Create Step Summary
109126 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+
110134 @"
111135 # MQPy Package
112136
@@ -142,7 +166,7 @@ jobs:
142166 This is a release candidate version published to Test PyPI.
143167
144168 ```
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/
146170 ```
147171 "@
148172 })
0 commit comments