|
| 1 | +name: Deploy | Publish Pypi Packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' # All branches for Test PyPI |
| 7 | + tags: |
| 8 | + - "*" |
| 9 | +jobs: |
| 10 | + build-and-publish: |
| 11 | + runs-on: windows-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: 3.8 |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: | |
| 24 | + python -m pip install --upgrade pip |
| 25 | + python -m pip install --upgrade setuptools |
| 26 | + python -m pip install poetry |
| 27 | + python -m pip install twine |
| 28 | + python -m poetry install |
| 29 | +
|
| 30 | + - name: Extract issue number |
| 31 | + id: issue |
| 32 | + if: startsWith(github.ref, 'refs/heads/') |
| 33 | + run: | |
| 34 | + $ISSUE_NUMBER = git log -1 --pretty=%B | Select-String -Pattern '#(\d+)' | ForEach-Object { $_.Matches.Groups[1].Value } |
| 35 | + if (-not $ISSUE_NUMBER) { $ISSUE_NUMBER = "dev" } |
| 36 | + echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $env:GITHUB_ENV |
| 37 | + echo "issue_number=$ISSUE_NUMBER" >> $env:GITHUB_OUTPUT |
| 38 | +
|
| 39 | + - name: Extract version from pyproject.toml |
| 40 | + id: version |
| 41 | + run: | |
| 42 | + $VERSION = (Get-Content pyproject.toml | Select-String -Pattern 'version = "(.*)"').Matches.Groups[1].Value |
| 43 | + echo "VERSION=$VERSION" >> $env:GITHUB_ENV |
| 44 | + echo "version=$VERSION" >> $env:GITHUB_OUTPUT |
| 45 | +
|
| 46 | + # For tags, extract the tag version |
| 47 | + if ("${{ github.ref }}".StartsWith("refs/tags/")) { |
| 48 | + $TAG_VERSION = "${{ github.ref }}".Substring(10) # Remove 'refs/tags/' prefix |
| 49 | + echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV |
| 50 | + } |
| 51 | +
|
| 52 | + - name: Build package |
| 53 | + run: | |
| 54 | + python -m poetry build |
| 55 | +
|
| 56 | + - name: Publish to Test PyPI (branch push) |
| 57 | + if: startsWith(github.ref, 'refs/heads/') |
| 58 | + env: |
| 59 | + TWINE_USERNAME: __token__ |
| 60 | + TWINE_PASSWORD: ${{ secrets.TEST_PYPI }} |
| 61 | + run: | |
| 62 | + # Rename dist files to include RC and issue number |
| 63 | + Get-ChildItem -Path dist -Filter "*.whl" | ForEach-Object { |
| 64 | + $newName = $_.Name -replace "(\d+\.\d+\.\d+)", "$1-rc${{ steps.issue.outputs.issue_number }}" |
| 65 | + Rename-Item -Path $_.FullName -NewName $newName |
| 66 | + } |
| 67 | + Get-ChildItem -Path dist -Filter "*.tar.gz" | ForEach-Object { |
| 68 | + $newName = $_.Name -replace "(\d+\.\d+\.\d+)", "$1-rc${{ steps.issue.outputs.issue_number }}" |
| 69 | + Rename-Item -Path $_.FullName -NewName $newName |
| 70 | + } |
| 71 | + twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/* |
| 72 | +
|
| 73 | + - name: Publish to PyPI (new tag) |
| 74 | + if: startsWith(github.ref, 'refs/tags/') |
| 75 | + env: |
| 76 | + TWINE_USERNAME: __token__ |
| 77 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 78 | + run: | |
| 79 | + twine upload dist/* |
| 80 | +
|
| 81 | + - name: Create Step Summary |
| 82 | + run: | |
| 83 | + @" |
| 84 | + # MQL5-Python Integration Package |
| 85 | +
|
| 86 | + ## Installation Instructions |
| 87 | +
|
| 88 | + ### Important Warning ⚠️ |
| 89 | + **DISCLAIMER: Using this package for automated trading carries significant financial risk. Users may lose money if not properly configured. Trade at your own risk.** |
| 90 | +
|
| 91 | + ### Windows-Only Compatibility |
| 92 | + This package is designed to work exclusively on Windows operating systems. |
| 93 | +
|
| 94 | + ### Installation Steps |
| 95 | +
|
| 96 | + $( if ("${{ github.ref }}".StartsWith("refs/tags/")) { |
| 97 | + @" |
| 98 | + #### Production Release |
| 99 | + This is an official release version (${{ env.TAG_VERSION }}) published to PyPI. |
| 100 | +
|
| 101 | + ``` |
| 102 | + pip install mql5-python-integration==${{ env.TAG_VERSION }} |
| 103 | + ``` |
| 104 | + "@ |
| 105 | + } else { |
| 106 | + @" |
| 107 | + #### Test/RC Version |
| 108 | + This is a release candidate version published to Test PyPI. |
| 109 | +
|
| 110 | + ``` |
| 111 | + 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/ |
| 112 | + ``` |
| 113 | + "@ |
| 114 | + }) |
| 115 | +
|
| 116 | + ### Documentation |
| 117 | + For complete documentation, visit our [GitHub repository](https://github.com/yourusername/mql5-python-integration). |
| 118 | + "@ | Out-File -FilePath $env:GITHUB_STEP_SUMMARY |
0 commit comments