Hopefully fix tag push issue #12
This file contains 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: pyMHF | |
on: | |
# Run on all branches except for the gh-pages branch | |
push: | |
paths-ignore: | |
- '*.md' | |
branches-ignore: | |
- 'gh-pages' | |
tags: | |
- '*' | |
jobs: | |
build_test: | |
name: Build artefacts | |
runs-on: Windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
py_ver: [{version: '3.9'}] # , {version: '3.10'}, {version: '3.11'}] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.py_ver.version}} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ matrix.py_ver.version}}" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip uv | |
uv sync --frozen --dev | |
- name: Build Python ${{ matrix.py_ver.version}} wheel | |
run: uv build | |
- name: Lint and format code | |
run: | | |
uv run ruff check ./pymhf | |
uv run ruff format --check ./pymhf | |
uv run python -m twine check ./dist/* | |
- name: Upload Wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
release: | |
name: Release pyMHF wheels and source build to PyPI | |
# Only run this job if the commit was tagged. | |
if: startsWith(github.ref, 'refs/tags') | |
needs: | |
- build_test | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/pyMHF | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Download files for release | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
attestations: true | |
test-release: | |
name: Release pyMHF wheels and source build to test-PyPI | |
needs: | |
- build_test | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/pyMHF | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Download files for release | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
attestations: true |