Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy | Publish Pypi Packages | |
| on: | |
| push: | |
| branches: | |
| - '**' # All branches for Test PyPI | |
| tags: | |
| - "*" | |
| jobs: | |
| build-and-publish: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.8 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --upgrade setuptools | |
| python -m pip install poetry | |
| python -m pip install twine | |
| python -m poetry install | |
| - name: Extract issue number | |
| id: issue | |
| if: startsWith(github.ref, 'refs/heads/') | |
| run: | | |
| $ISSUE_NUMBER = git log -1 --pretty=%B | Select-String -Pattern '#(\d+)' | ForEach-Object { $_.Matches.Groups[1].Value } | |
| if (-not $ISSUE_NUMBER) { $ISSUE_NUMBER = "dev" } | |
| echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $env:GITHUB_ENV | |
| echo "issue_number=$ISSUE_NUMBER" >> $env:GITHUB_OUTPUT | |
| - name: Extract version from pyproject.toml | |
| id: version | |
| run: | | |
| $VERSION = (Get-Content pyproject.toml | Select-String -Pattern 'version = "(.*)"').Matches.Groups[1].Value | |
| echo "VERSION=$VERSION" >> $env:GITHUB_ENV | |
| echo "version=$VERSION" >> $env:GITHUB_OUTPUT | |
| # For tags, extract the tag version | |
| if ("${{ github.ref }}".StartsWith("refs/tags/")) { | |
| $TAG_VERSION = "${{ github.ref }}".Substring(10) # Remove 'refs/tags/' prefix | |
| echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV | |
| } | |
| - name: Build package | |
| run: | | |
| python -m poetry build | |
| - name: Publish to Test PyPI (branch push) | |
| if: startsWith(github.ref, 'refs/heads/') | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI }} | |
| run: | | |
| # Rename dist files to include RC and issue number | |
| Get-ChildItem -Path dist -Filter "*.whl" | ForEach-Object { | |
| $newName = $_.Name -replace "(\d+\.\d+\.\d+)", "$1-rc${{ steps.issue.outputs.issue_number }}" | |
| Rename-Item -Path $_.FullName -NewName $newName | |
| } | |
| Get-ChildItem -Path dist -Filter "*.tar.gz" | ForEach-Object { | |
| $newName = $_.Name -replace "(\d+\.\d+\.\d+)", "$1-rc${{ steps.issue.outputs.issue_number }}" | |
| Rename-Item -Path $_.FullName -NewName $newName | |
| } | |
| twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/* | |
| - name: Publish to PyPI (new tag) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: | | |
| twine upload dist/* | |
| - name: Create Step Summary | |
| run: | | |
| @" | |
| # MQL5-Python Integration Package | |
| ## Installation Instructions | |
| ### Important Warning ⚠️ | |
| **DISCLAIMER: Using this package for automated trading carries significant financial risk. Users may lose money if not properly configured. Trade at your own risk.** | |
| ### Windows-Only Compatibility | |
| This package is designed to work exclusively on Windows operating systems. | |
| ### Installation Steps | |
| $( if ("${{ github.ref }}".StartsWith("refs/tags/")) { | |
| @" | |
| #### Production Release | |
| This is an official release version (${{ env.TAG_VERSION }}) published to PyPI. | |
| ``` | |
| pip install mql5-python-integration==${{ env.TAG_VERSION }} | |
| ``` | |
| "@ | |
| } else { | |
| @" | |
| #### Test/RC Version | |
| This is a release candidate version published to Test PyPI. | |
| ``` | |
| pip install mql5-python-integration==${{ env.VERSION }}-rc${{ env.ISSUE_NUMBER }} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ | |
| ``` | |
| "@ | |
| }) | |
| ### Documentation | |
| For complete documentation, visit our [GitHub repository](https://github.com/yourusername/mql5-python-integration). | |
| "@ | Out-File -FilePath $env:GITHUB_STEP_SUMMARY |