Skip to content

Update GitHub actions #39

Update GitHub actions

Update GitHub actions #39

name: Build and publish to TestPyPI or PyPI
on: [push, pull_request]
jobs:
get_python_versions:
name: "Determine Python versions"
runs-on: ubuntu-latest
outputs:
min-python: ${{ steps.nep29.outputs.min-python }}
max-python: ${{ steps.nep29.outputs.max-python }}
steps:
- name: "calculate versions according to NEP29"
id: nep29
uses: mstimberg/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
build:
needs: [get_python_versions]
name: Build 🎑 and source πŸ“¦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # we need the full history for the version calculation
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build source tarball and noarch wheel
run: |
python -m pip install --upgrade pip build wheel
python -m build
- name: store distribution πŸ“¦
uses: actions/upload-artifact@v4
with:
name: packages
path: dist
deploy_dev:
name: Publish development πŸ“¦ to TestPyPI
runs-on: ubuntu-latest
if: github.repository == 'brian-team/brian2genn' && github.ref == 'refs/heads/master'
environment: development_release
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
needs:
- build
steps:
- name: load distribution πŸ“¦
uses: actions/download-artifact@v4
with:
name: packages
path: dist/
- name: Publish distribution πŸ“¦ to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
deploy:
name: Publish release πŸ“¦ to PyPI
runs-on: ubuntu-latest
if: github.repository == 'brian-team/brian2genn' && startsWith(github.ref, 'refs/tags')
environment: release
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
needs:
- build
steps:
- name: load distribution πŸ“¦
uses: actions/download-artifact@v4
with:
name: packages
path: dist/
- name: Publish distribution release πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1