r2, risk_of_ruin #4
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: read | |
| jobs: | |
| build: | |
| name: Build distributions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| - name: Install build backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build | |
| - name: Validate tag version | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| python - <<'PY' | |
| import tomllib | |
| from pathlib import Path | |
| tag = "${{ github.ref }}".split("/")[-1] | |
| if not tag.startswith("v"): | |
| raise SystemExit("Release tags must be prefixed with 'v'") | |
| tag_version = tag.removeprefix("v") | |
| data = tomllib.loads(Path("pyproject.toml").read_text()) | |
| project_version = data["project"]["version"] | |
| if project_version != tag_version: | |
| raise SystemExit( | |
| f"Version mismatch: pyproject.toml has {project_version} but tag is {tag_version}" | |
| ) | |
| PY | |
| - name: Build distributions | |
| run: python -m build | |
| - name: Upload distributions artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-packages | |
| path: dist/ | |
| if-no-files-found: error | |
| publish: | |
| name: Publish to PyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/quantalytics/ | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-packages | |
| path: dist | |
| - name: Publish distribution | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| release: | |
| name: Create GitHub release | |
| needs: publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-packages | |
| path: dist | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| generate_release_notes: true |