-
-
Notifications
You must be signed in to change notification settings - Fork 55
176 lines (145 loc) · 6.07 KB
/
deploy-pypi-packages.yaml
File metadata and controls
176 lines (145 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Deploy | Publish Pypi Packages
on:
workflow_dispatch:
push:
branches:
- '**' # All branches for Test PyPI
tags:
- "*"
jobs:
build-and-publish:
runs-on: windows-latest
steps:
- uses: actions/checkout@v5
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 wheel build twine
- name: Clean dist directory
run: |
if (Test-Path -Path dist) { Remove-Item dist -Recurse -Force }
- name: Extract issue number and suffix
id: issue
if: startsWith(github.ref, 'refs/heads/')
run: |
# Look for #<number> in commit message
$match = git log -1 --pretty=%B | Select-String -Pattern '#(\d+)'
if ($match) {
$num = $match.Matches.Groups[1].Value
$suffix = "rc$num"
} else {
# No issue number => development build
$suffix = 'dev0'
}
echo "SUFFIX=$suffix" >> $env:GITHUB_ENV
echo "suffix=$suffix" >> $env:GITHUB_OUTPUT
- name: Extract version from pyproject.toml
id: version
run: |
$verLine = Get-Content pyproject.toml | Select-String -Pattern 'version = "(.*)"'
$VERSION = $verLine.Matches.Groups[1].Value -replace '^v', ''
echo "VERSION=$VERSION" >> $env:GITHUB_ENV
echo "version=$VERSION" >> $env:GITHUB_OUTPUT
if ("${{ github.ref }}".StartsWith('refs/tags/')) {
$TAG_VERSION = "${{ github.ref }}".Substring(10) -replace '^v', ''
echo "TAG_VERSION=$TAG_VERSION" >> $env:GITHUB_ENV
}
- name: Create temporary pyproject.toml for test build
if: startsWith(github.ref, 'refs/heads/')
run: |
# Read the current pyproject.toml
$content = Get-Content pyproject.toml -Raw
# Get the current version
$version = "${{ env.VERSION }}"
$suffix = "${{ env.SUFFIX }}"
# Update the version with the suffix
$newVersion = "$version.$suffix"
# Replace the version in the content
$updatedContent = $content -replace 'version = "(.*?)"', "version = `"$newVersion`""
# Save to a temporary file
$updatedContent | Out-File -FilePath pyproject.toml.temp -Encoding utf8
# Show the changes
Write-Host "Original version: $version"
Write-Host "Updated version: $newVersion"
# Backup original and replace with temp version
Move-Item -Path pyproject.toml -Destination pyproject.toml.bak -Force
Move-Item -Path pyproject.toml.temp -Destination pyproject.toml -Force
- name: Build package for Test PyPI
if: startsWith(github.ref, 'refs/heads/')
run: |
python -m build
# After building, restore the original pyproject.toml
Move-Item -Path pyproject.toml.bak -Destination pyproject.toml -Force
- name: Build package for PyPI
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
run: |
python -m build
- name: Check distributions
run: |
twine check dist/*
- name: Publish to Test PyPI (branch push)
if: startsWith(github.ref, 'refs/heads/')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI }}
run: |
Write-Host "Files ready for upload:"
Get-ChildItem dist/* | ForEach-Object { Write-Host " $_" }
# Upload with verbose output for debugging
twine upload --skip-existing --verbose --repository-url https://test.pypi.org/legacy/ dist/*
- name: Publish to PyPI (new tag or workflow dispatch)
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
Write-Host "Files to upload to PyPI:"
Get-ChildItem dist/* | ForEach-Object { Write-Host " $_" }
twine upload --verbose dist/*
- name: Create Step Summary
run: |
# Set the display version based on the ref
if ("${{ github.ref }}".StartsWith("refs/tags/")) {
$displayVersion = "${{ env.TAG_VERSION }}"
} else {
$displayVersion = "${{ env.VERSION }}.${{ env.SUFFIX }}"
}
@"
# MQPy Package
## Installation Instructions
### Important Warning ⚠️
**IMPORTANT: Trading involves substantial risk of loss and is not suitable for all investors.**
- Always use a **demo account** with fake money when testing strategies
- MQPy is provided for **educational purposes only**
- Past performance is not indicative of future results
- Never trade with money you cannot afford to lose
- The developers are not responsible for any financial losses
### 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 mqpy==${{ env.TAG_VERSION }}
```
"@
} else {
@"
#### Test/RC Version
This is a release candidate version published to Test PyPI.
```
pip install mqpy==$displayVersion --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/Joaopeuko/Mql5-Python-Integration).
"@ | Out-File -FilePath $env:GITHUB_STEP_SUMMARY