Skip to content

fix: Fix all the broken changes from the last pr #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7001e59
fix parts of broken part
Joaopeuko Apr 26, 2025
712f043
add some improvements
Joaopeuko Apr 26, 2025
fe6e991
lock
Joaopeuko Apr 26, 2025
9cfb5be
no uv
Joaopeuko Apr 26, 2025
4aa882a
pytest
Joaopeuko Apr 26, 2025
b3fcc45
extra
Joaopeuko Apr 26, 2025
8e59823
tick
Joaopeuko Apr 26, 2025
e329487
windows
Joaopeuko Apr 26, 2025
f020378
windows
Joaopeuko Apr 26, 2025
03a4d3c
summary
Joaopeuko Apr 26, 2025
7fcfaa5
pre-commit
Joaopeuko Apr 26, 2025
e7015f5
pre-commit
Joaopeuko Apr 26, 2025
82b727d
pytest and pre-commit
Joaopeuko Apr 27, 2025
f519842
Pytest rates
Joaopeuko Apr 27, 2025
8e3b7ab
integration
Joaopeuko Apr 27, 2025
2398bb2
Improve GitHub Actions, removing redundancy
Joaopeuko Apr 27, 2025
034baa8
Pytest utilities
Joaopeuko Apr 27, 2025
5152cab
Pytest trade.py
Joaopeuko Apr 27, 2025
dd39df5
template
Joaopeuko Apr 27, 2025
ff6384e
main readme
Joaopeuko Apr 27, 2025
5f82df4
improve documentation
Joaopeuko Apr 27, 2025
f1e7ecd
add logger
Joaopeuko Apr 27, 2025
2ff2546
pypi
Joaopeuko Apr 27, 2025
ac8595d
release
Joaopeuko Apr 27, 2025
0637168
release
Joaopeuko Apr 27, 2025
0e0fa8b
package
Joaopeuko Apr 27, 2025
478de3d
package
Joaopeuko Apr 27, 2025
c5f5203
package
Joaopeuko Apr 27, 2025
640f017
release
Joaopeuko Apr 27, 2025
5ef8adf
package
Joaopeuko Apr 27, 2025
f9bf19a
after the working version
Joaopeuko Apr 27, 2025
b9d6db9
warning
Joaopeuko Apr 27, 2025
24df7de
get the version
Joaopeuko Apr 27, 2025
8e4bd77
dry run
Joaopeuko Apr 27, 2025
b3c7245
release
Joaopeuko Apr 27, 2025
f4f0a47
release
Joaopeuko Apr 27, 2025
4fba043
duplicated
Joaopeuko Apr 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions .github/workflows/deploy-pypi-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
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 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/')
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)
if: startsWith(github.ref, 'refs/tags/')
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
154 changes: 153 additions & 1 deletion .github/workflows/deploy-semantic-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@ name: Deploy | Semantic Release

on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (no changes will be committed)'
type: boolean
default: false
debug:
description: 'Enable verbose debugging output'
type: boolean
default: false
push:
branches:
- '**'
paths-ignore:
- 'docs/**'
- '*.md'
- '.github/workflows/deploy-pypi-packages.yaml'

jobs:
release:
runs-on: windows-latest
runs-on: ubuntu-latest
concurrency: release
permissions:
contents: write
Expand All @@ -16,9 +32,145 @@ jobs:
with:
fetch-depth: 0

- name: Set run mode
id: set_mode
shell: bash
run: |
IS_DRY_RUN=$([ "${{ github.event_name }}" = "push" ] || [ "${{ inputs.dry_run }}" = "true" ] && echo "true" || echo "false")
echo "is_dry_run=$IS_DRY_RUN" >> $GITHUB_OUTPUT
echo "Mode: $([ "$IS_DRY_RUN" = "true" ] && echo "Dry run" || echo "Full release")"

- name: Python Release - Dry Run
id: release_dryrun
if: steps.set_mode.outputs.is_dry_run == 'true'
uses: python-semantic-release/python-semantic-release@v9.20.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
push: "false"
commit: "false"
tag: "false"
changelog: "false"
root_options: ${{ inputs.debug && '-vv --noop' || '-v --noop' }}

- name: Extract Next Version Info
id: extract_next_version
if: steps.set_mode.outputs.is_dry_run == 'true' && steps.release_dryrun.outputs.version == ''
shell: bash
run: |
# When no release is needed, semantic-release doesn't output the next version
# We need to determine it manually from the commit history

# Check if we have commits that would trigger a version bump
FEAT_COMMITS=$(git log --grep="^feat:" -i --pretty=format:"%h" | wc -l)
FIX_COMMITS=$(git log --grep="^fix:" -i --pretty=format:"%h" | wc -l)
BREAKING_COMMITS=$(git log --grep="BREAKING CHANGE:" -i --pretty=format:"%h" | wc -l)

# Get current version from pyproject.toml
CURRENT_VERSION=$(grep -m 1 'version = "' pyproject.toml | awk -F'"' '{print $2}' | sed 's/^v//')
echo "Current version: $CURRENT_VERSION"

# Split current version into components
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"

# Determine the next version based on conventional commits
if [ "$BREAKING_COMMITS" -gt 0 ]; then
# Major version bump
NEXT_VERSION="$((MAJOR + 1)).0.0"
elif [ "$FEAT_COMMITS" -gt 0 ]; then
# Minor version bump
NEXT_VERSION="$MAJOR.$((MINOR + 1)).0"
elif [ "$FIX_COMMITS" -gt 0 ]; then
# Patch version bump
NEXT_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
else
# No significant changes, use development version
NEXT_VERSION="${CURRENT_VERSION}.dev0"
fi

echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "next_tag=v$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Determined next version: $NEXT_VERSION"

- name: Python Release
id: release
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.dry_run }}
uses: python-semantic-release/python-semantic-release@v9.20.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
push: "true"
changelog: "true"
root_options: ${{ inputs.debug && '-vv' || '-v' }}

- name: Create Step Summary
shell: bash
run: |
IS_DRY_RUN="${{ steps.set_mode.outputs.is_dry_run }}"
RELEASE_ID=$([ "$IS_DRY_RUN" = "true" ] && echo "release_dryrun" || echo "release")
WAS_RELEASED=$([ "${{ steps.release_dryrun.outputs.released || steps.release.outputs.released }}" = "true" ] && echo "Yes" || echo "No")

# First try to get version from release outputs
VERSION="${{ steps.release_dryrun.outputs.version || steps.release.outputs.version }}"
TAG="${{ steps.release_dryrun.outputs.tag || steps.release.outputs.tag }}"

# If no version from release outputs, try to get from extract_next_version step
if [ "$IS_DRY_RUN" = "true" ] && [ -z "$VERSION" ]; then
VERSION="${{ steps.extract_next_version.outputs.next_version }}"
TAG="${{ steps.extract_next_version.outputs.next_tag }}"
fi

# Display trigger information
if [ "${{ github.event_name }}" = "push" ]; then
TRIGGER_INFO="Triggered by push to branch: ${{ github.ref_name }}"
else
TRIGGER_INFO="Triggered manually via workflow dispatch"
fi

# Create warning text for dry run
if [ "$IS_DRY_RUN" = "true" ]; then
DRY_RUN_TEXT="⚠️ This is a dry run - no changes were committed"
TITLE_SUFFIX=" (Dry Run)"
else
DRY_RUN_TEXT=""
TITLE_SUFFIX=""
fi

cat > $GITHUB_STEP_SUMMARY << EOF
# MQPy Release$TITLE_SUFFIX

## Release Summary

$TRIGGER_INFO
$DRY_RUN_TEXT

Current/Next Version: $VERSION
Current/Next Tag: $TAG
Release required: $WAS_RELEASED

## 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

#### $([ "$IS_DRY_RUN" = "true" ] && echo "Test/RC Version" || echo "Production Version")
$([ "$IS_DRY_RUN" = "true" ] && echo "This is a release candidate version published to Test PyPI.

\`\`\`
pip install mqpy==$VERSION --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
\`\`\`" || echo "\`\`\`
pip install mqpy==$VERSION
\`\`\`")

### Documentation
For complete documentation, visit our [GitHub repository](https://github.com/Joaopeuko/Mql5-Python-Integration).
EOF
43 changes: 0 additions & 43 deletions .github/workflows/deploy.yaml

This file was deleted.

Loading