|
| 1 | +name: Build & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['**'] |
| 6 | + pull_request: |
| 7 | + branches: ['**'] |
| 8 | + workflow_dispatch: |
| 9 | + # Allow workflow to be triggered manually. |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: build-test (python ${{ matrix.python-version }}) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: ['3.10', '3.11', '3.12', '3.13'] |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + cache: 'pip' |
| 29 | + |
| 30 | + - name: Install pandoc |
| 31 | + run: | |
| 32 | + sudo apt-get update |
| 33 | + sudo apt-get install pandoc |
| 34 | + pip install pypandoc |
| 35 | +
|
| 36 | + - name: Install dependencies |
| 37 | + run: pip install 'tox<4' tox-gh-actions |
| 38 | + |
| 39 | + - name: Run tests |
| 40 | + run: tox |
| 41 | + |
| 42 | + create-release: |
| 43 | + name: semantic-release |
| 44 | + if: "github.ref_name == 'master' && github.event_name != 'pull_request'" |
| 45 | + needs: build |
| 46 | + runs-on: ubuntu-latest |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout repository |
| 50 | + uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + persist-credentials: false |
| 53 | + fetch-depth: 0 |
| 54 | + |
| 55 | + - name: Setup Node.js |
| 56 | + uses: actions/setup-node@v4 |
| 57 | + with: |
| 58 | + node-version: 22 |
| 59 | + |
| 60 | + - name: Setup Python |
| 61 | + uses: actions/setup-python@v5 |
| 62 | + with: |
| 63 | + python-version: '3.10' |
| 64 | + |
| 65 | + - name: Install Publishing Tools |
| 66 | + run: | |
| 67 | + pip install bump2version build twine |
| 68 | + npm install |
| 69 | +
|
| 70 | + - name: Run semantic-release |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 73 | + run: npx semantic-release |
| 74 | + |
| 75 | + - name: Publish to PyPI |
| 76 | + if: success() |
| 77 | + env: |
| 78 | + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 79 | + run: | |
| 80 | + python -m build |
| 81 | + python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN |
0 commit comments