Skip to content

Commit 5ef8adf

Browse files
committed
package
1 parent 640f017 commit 5ef8adf

File tree

2 files changed

+83
-48
lines changed

2 files changed

+83
-48
lines changed

.github/workflows/deploy-pypi-packages.yaml

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,43 @@ jobs:
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
})

.github/workflows/deploy-semantic-release.yaml

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121

2222
jobs:
2323
release:
24-
runs-on: windows-latest
24+
runs-on: ubuntu-latest
2525
concurrency: release
2626
permissions:
2727
contents: write
@@ -34,14 +34,15 @@ jobs:
3434

3535
- name: Set run mode
3636
id: set_mode
37+
shell: bash
3738
run: |
38-
$isDryRun = "${{ github.event_name == 'push' || inputs.dry_run }}" -eq "true"
39-
echo "is_dry_run=$isDryRun" >> $env:GITHUB_OUTPUT
40-
echo "Mode: $($isDryRun ? 'Dry run' : 'Full release')"
39+
IS_DRY_RUN=$([ "${{ github.event_name }}" = "push" ] || [ "${{ inputs.dry_run }}" = "true" ] && echo "true" || echo "false")
40+
echo "is_dry_run=$IS_DRY_RUN" >> $GITHUB_OUTPUT
41+
echo "Mode: $([ "$IS_DRY_RUN" = "true" ] && echo "Dry run" || echo "Full release")"
4142
4243
- name: Python Release - Dry Run
4344
id: release_dryrun
44-
if: steps.set_mode.outputs.is_dry_run == 'True'
45+
if: steps.set_mode.outputs.is_dry_run == 'true'
4546
uses: python-semantic-release/python-semantic-release@v9.20.0
4647
with:
4748
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -62,31 +63,41 @@ jobs:
6263
root_options: ${{ inputs.debug && '-vv' || '-v' }}
6364

6465
- name: Create Step Summary
66+
shell: bash
6567
run: |
66-
$isDryRun = "${{ steps.set_mode.outputs.is_dry_run }}" -eq "True"
67-
$releaseId = $isDryRun ? "release_dryrun" : "release"
68-
$wasReleased = "${{ steps.release_dryrun.outputs.released || steps.release.outputs.released }}" -eq "true"
69-
$version = "${{ steps.release_dryrun.outputs.version || steps.release.outputs.version }}"
70-
$tag = "${{ steps.release_dryrun.outputs.tag || steps.release.outputs.tag }}"
68+
IS_DRY_RUN="${{ steps.set_mode.outputs.is_dry_run }}"
69+
RELEASE_ID=$([ "$IS_DRY_RUN" = "true" ] && echo "release_dryrun" || echo "release")
70+
WAS_RELEASED=$([ "${{ steps.release_dryrun.outputs.released || steps.release.outputs.released }}" = "true" ] && echo "Yes" || echo "No")
71+
VERSION="${{ steps.release_dryrun.outputs.version || steps.release.outputs.version }}"
72+
TAG="${{ steps.release_dryrun.outputs.tag || steps.release.outputs.tag }}"
7173
7274
# Display trigger information
73-
$triggerInfo = if ("${{ github.event_name }}" -eq "push") {
74-
"Triggered by push to branch: ${{ github.ref_name }}"
75-
} else {
76-
"Triggered manually via workflow dispatch"
77-
}
78-
79-
@"
80-
# MQPy Release $($isDryRun ? "(Dry Run)" : "")
75+
if [ "${{ github.event_name }}" = "push" ]; then
76+
TRIGGER_INFO="Triggered by push to branch: ${{ github.ref_name }}"
77+
else
78+
TRIGGER_INFO="Triggered manually via workflow dispatch"
79+
fi
80+
81+
# Create warning text for dry run
82+
if [ "$IS_DRY_RUN" = "true" ]; then
83+
DRY_RUN_TEXT="⚠️ This is a dry run - no changes were committed"
84+
TITLE_SUFFIX=" (Dry Run)"
85+
else
86+
DRY_RUN_TEXT=""
87+
TITLE_SUFFIX=""
88+
fi
89+
90+
cat > $GITHUB_STEP_SUMMARY << EOF
91+
# MQPy Release$TITLE_SUFFIX
8192
8293
## Release Summary
8394
84-
$triggerInfo
85-
$($isDryRun ? "⚠️ This is a dry run - no changes were committed" : "")
95+
$TRIGGER_INFO
96+
$DRY_RUN_TEXT
8697
87-
Current/Next Version: $version
88-
Current/Next Tag: $tag
89-
Release required: $($wasReleased ? "Yes" : "No")
98+
Current/Next Version: $VERSION
99+
Current/Next Tag: $TAG
100+
Release required: $WAS_RELEASED
90101
91102
## Installation Instructions
92103
@@ -105,10 +116,10 @@ jobs:
105116
106117
### Installation Steps
107118
108-
```
109-
pip install mqpy==$version
110-
```
119+
\`\`\`
120+
pip install mqpy==$VERSION
121+
\`\`\`
111122
112123
### Documentation
113124
For complete documentation, visit our [GitHub repository](https://github.com/Joaopeuko/Mql5-Python-Integration).
114-
"@ | Out-File -FilePath $env:GITHUB_STEP_SUMMARY
125+
EOF

0 commit comments

Comments
 (0)