add Fockerfile (como dice @Rick-29) #317
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: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| RUSTC_WRAPPER: sccache | |
| SCCACHE_GHA_ENABLED: "true" | |
| jobs: | |
| # --- 0. DOCS --- | |
| docs: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure Git Credentials | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.x | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Install dependencies with uv | |
| run: uv pip install --system mkdocs-material "mkdocstrings[python]" | |
| - run: mkdocs gh-deploy --force | |
| # --- 1. LINUX BUILD --- | |
| linux: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # Define specific Rust targets for Zig to handle | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| libc: manylinux_2_28 | |
| - target: x86_64-unknown-linux-musl | |
| libc: musllinux_1_1 | |
| - target: aarch64-unknown-linux-gnu | |
| libc: manylinux_2_28 | |
| - target: aarch64-unknown-linux-musl | |
| libc: musllinux_1_1 | |
| - target: armv7-unknown-linux-gnueabihf | |
| libc: manylinux_2_28 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run sccache-cache | |
| uses: mozilla/sccache-action@v0.0.6 | |
| - name: Install Zig | |
| uses: mlugg/setup-zig@v1 | |
| with: | |
| version: 0.13.0 # Explicitly use stable to avoid 404s | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| # --zig handles the cross-compilation and linking for GLIBC/MUSL | |
| args: --release --strip --out dist -i python3.13 --zig | |
| manylinux: ${{ matrix.libc }} | |
| working-directory: BinaryOptionsToolsV2 | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-linux-${{ matrix.target }} | |
| path: BinaryOptionsToolsV2/dist | |
| # --- 2. WINDOWS BUILD --- | |
| windows: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [x64, x86] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run sccache-cache | |
| uses: mozilla/sccache-action@v0.0.6 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13.12" | |
| architecture: ${{ matrix.target }} | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| args: --release --strip --out dist -i python3.13 | |
| working-directory: BinaryOptionsToolsV2 | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-windows-${{ matrix.target }} | |
| path: BinaryOptionsToolsV2/dist | |
| # --- 3. MACOS BUILD --- | |
| macos: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run sccache-cache | |
| uses: mozilla/sccache-action@v0.0.6 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13.12" | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: universal2-apple-darwin | |
| args: --release --strip --out dist -i python3.13 | |
| working-directory: BinaryOptionsToolsV2 | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-macos | |
| path: BinaryOptionsToolsV2/dist | |
| # --- 4. SOURCE DISTRIBUTION --- | |
| sdist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run sccache-cache | |
| uses: mozilla/sccache-action@v0.0.6 | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist -m rust/Cargo.toml | |
| working-directory: BinaryOptionsToolsV2 | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-sdist | |
| path: BinaryOptionsToolsV2/dist | |
| # --- 5. AUTOMATED RELEASE --- | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [linux, windows, macos, sdist] | |
| permissions: | |
| contents: write | |
| outputs: | |
| has_pypi_token: ${{ steps.check_token.outputs.has_token }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check for PyPI token | |
| id: check_token | |
| run: | | |
| if [ -n "${{ secrets.PYPI_API_TOKEN }}" ]; then | |
| echo "has_token=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_token=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get Version from Cargo.toml | |
| id: get_version | |
| working-directory: BinaryOptionsToolsV2 | |
| run: | | |
| # The runner has python3 installed; tomllib is built-in since 3.11 | |
| VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('rust/Cargo.toml', 'rb'))['package']['version'])") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "TAG=v$VERSION" >> $GITHUB_OUTPUT | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: wheels | |
| pattern: wheels-* | |
| merge-multiple: true | |
| - name: Sync GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG: ${{ steps.get_version.outputs.TAG }} | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| run: | | |
| if gh release view "$TAG" > /dev/null 2>&1; then | |
| echo "Updating existing release $TAG..." | |
| gh release upload "$TAG" wheels/*.whl --clobber | |
| else | |
| echo "Creating new release $TAG..." | |
| gh release create "$TAG" wheels/*.whl \ | |
| --title "BinaryOptionsToolsV2 $VERSION" \ | |
| --generate-notes \ | |
| --notes "### Automated Release $TAG | |
| Built natively for Python 3.13.12." | |
| fi | |
| - name: Summary | |
| run: | | |
| echo "### Automatic build success, more info below." >> $GITHUB_STEP_SUMMARY | |
| echo "- **Platform:** macOS Sequoia / Ubuntu 24.04 / Windows Server 2022" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Python:** 3.13.12 (Stable)" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version:** ${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY | |
| # --- 6. PYPI PUBLISH --- | |
| pypi-publish: | |
| name: PyPI Publish | |
| runs-on: ubuntu-latest | |
| needs: [release, linux, windows, macos, sdist] | |
| # Skip if secrets.PYPI_API_TOKEN is not set or if not on a main/master branch push | |
| if: (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) && needs.release.outputs.has_pypi_token == 'true' | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: wheels-* | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| skip-existing: true | |
| packages-dir: dist/ | |
| verify-metadata: false |