Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: CI
2
3 on:
4 push:
5 branches:
6 - main
7 pull_request:
8
9 concurrency:
10 group: ${{ github.head_ref || github.run_id }}
11 cancel-in-progress: true
12
13 jobs:
14 lint:
15 runs-on: ubuntu-latest
16 steps:
17 - uses: actions/checkout@v4
18 - uses: actions/setup-python@v5
19 with:
20 python-version: 3.x
21 - uses: pre-commit/[email protected]
22
23 # Make sure commit messages follow the conventional commits convention:
24 # https://www.conventionalcommits.org
25 commitlint:
26 name: Lint Commit Messages
27 runs-on: ubuntu-latest
28 steps:
29 - uses: actions/checkout@v4
30 with:
31 fetch-depth: 0
32 - uses: wagoid/[email protected]
33
34 test:
35 strategy:
36 fail-fast: false
37 matrix:
38 python-version:
39 - "3.12"
40 - "3.13"
41 os:
42 - ubuntu-latest
43 - windows-latest
44 - macOS-latest
45 runs-on: ${{ matrix.os }}
46 steps:
47 - uses: actions/checkout@v4
48 - uses: actions/setup-python@v5
49 id: setup-python
50 with:
51 python-version: ${{ matrix.python-version }}
52 - uses: astral-sh/setup-uv@v5
53 - run: uv sync --no-python-downloads
54 shell: bash
55 - run: uv run pytest
56 shell: bash
57 - uses: codecov/codecov-action@v5
58 with:
59 token: ${{ secrets.CODECOV_TOKEN }}
60
61 release:
62 needs:
63 - test
64 - lint
65 - commitlint
66
67 runs-on: ubuntu-latest
68 environment: release
69 concurrency: release
70 permissions:
71 id-token: write
72 attestations: write
73 contents: write
74
75 steps:
76 - uses: actions/checkout@v4
77 with:
78 fetch-depth: 0
79 ref: ${{ github.sha }}
80
81 - name: Checkout commit for release
82 run: |
83 git checkout -B ${{ github.ref_name }} ${{ github.sha }}
84
85 # Do a dry run of PSR
86 - name: Test release
87 uses: python-semantic-release/[email protected]
88 if: github.ref_name != 'main'
89 with:
90 root_options: --noop
91 github_token: noop
92
93 # On main branch: actual PSR + upload to PyPI & GitHub
94 - name: Release
95 uses: python-semantic-release/[email protected]
96 id: release
97 if: github.ref_name == 'main'
98 with:
99 github_token: ${{ secrets.GITHUB_TOKEN }}
100
101 - name: Attest build provenance
102 uses: actions/attest-build-provenance@v1
103 if: steps.release.outputs.released == 'true'
104 with:
105 subject-path: "dist/*"
106
107 - name: Publish package distributions to PyPI
108 uses: pypa/gh-action-pypi-publish@release/v1
109 if: steps.release.outputs.released == 'true'
110
111 - name: Publish package distributions to GitHub Releases
112 uses: python-semantic-release/[email protected]
113 if: steps.release.outputs.released == 'true'
114 with:
115 github_token: ${{ secrets.GITHUB_TOKEN }}
116 tag: ${{ steps.release.outputs.tag }}