|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + schedule: |
| 9 | + # Daily at 6:43 |
| 10 | + - cron: "43 6 * * *" |
| 11 | + |
| 12 | +env: |
| 13 | + PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 14 | + PIP_NO_PYTHON_VERSION_WARNING: "1" |
| 15 | + PYTHON_LATEST: "3.11" |
| 16 | + |
| 17 | +jobs: |
| 18 | + pre-commit: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + - uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: ${{ env.PYTHON_LATEST }} |
| 25 | + - uses: pre-commit/[email protected] |
| 26 | + |
| 27 | + list: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + outputs: |
| 30 | + noxenvs: ${{ steps.noxenvs-matrix.outputs.noxenvs }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v3 |
| 33 | + - name: Set up nox |
| 34 | + |
| 35 | + - id: noxenvs-matrix |
| 36 | + run: | |
| 37 | + echo >>$GITHUB_OUTPUT noxenvs=$( |
| 38 | + nox --list-sessions | |
| 39 | + grep '^* ' | |
| 40 | + cut -d ' ' -f 2- | |
| 41 | + jq --raw-input --slurp 'split("\n") | map(select(. != ""))' |
| 42 | + ) |
| 43 | +
|
| 44 | + ci: |
| 45 | + needs: list |
| 46 | + runs-on: ${{ matrix.os }} |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + os: [macos-latest, ubuntu-latest] |
| 51 | + noxenv: ${{ fromJson(needs.list.outputs.noxenvs) }} |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v3 |
| 55 | + - name: Install dependencies |
| 56 | + run: > |
| 57 | + sudo apt-get update && |
| 58 | + sudo apt-get install -y libenchant-2-dev |
| 59 | + if: runner.os == 'Linux' |
| 60 | + - name: Install dependencies |
| 61 | + run: brew install enchant |
| 62 | + if: runner.os == 'macOS' |
| 63 | + - name: Set up Python |
| 64 | + uses: actions/setup-python@v4 |
| 65 | + with: |
| 66 | + python-version: ${{ env.PYTHON_LATEST }} |
| 67 | + - name: Set up nox |
| 68 | + |
| 69 | + - name: Run nox |
| 70 | + run: nox -s ${{ matrix.noxenv }} |
| 71 | + |
| 72 | + packaging: |
| 73 | + needs: ci |
| 74 | + runs-on: ubuntu-latest |
| 75 | + |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v3 |
| 78 | + - name: Set up Python |
| 79 | + uses: actions/setup-python@v4 |
| 80 | + with: |
| 81 | + python-version: ${{ env.PYTHON_LATEST }} |
| 82 | + - name: Install dependencies |
| 83 | + run: python -m pip install build |
| 84 | + - name: Create packages |
| 85 | + run: python -m build . |
| 86 | + - uses: actions/upload-artifact@v3 |
| 87 | + with: |
| 88 | + name: dist |
| 89 | + path: dist |
| 90 | + - name: Publish the package |
| 91 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 92 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 93 | + with: |
| 94 | + password: ${{ secrets.pypi_password }} |
| 95 | + - name: Create a Release |
| 96 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 97 | + uses: actions/github-script@v6 |
| 98 | + with: |
| 99 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + script: | |
| 102 | + await github.request(`POST /repos/${{ github.repository }}/releases`, { |
| 103 | + tag_name: "${{ github.ref }}", |
| 104 | + generate_release_notes: true |
| 105 | + }); |
| 106 | +
|
0 commit comments