Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: Build + Deploy
2
3 on:
4 push:
5 branches: [main]
6 tags: ["*.*.*"]
7 pull_request:
8 branches: [main]
9
10 env:
11 CIBW_TEST_REQUIRES: "pytest -rrequirements.txt"
12 CIBW_TEST_COMMAND: "pytest --pyargs compreffor"
13 CIBW_ENABLE: "pypy"
14
15 jobs:
16
17 build_sdist:
18 name: Build Source Distribution
19 runs-on: ubuntu-latest
20 steps:
21 - uses: actions/checkout@v6
22 with:
23 submodules: recursive
24 # setuptools_scm won't work with shallow clone; fetch all history
25 fetch-depth: 0
26 - name: Set up Python
27 uses: actions/setup-python@v6
28 with:
29 python-version: "3.x"
30 - name: Build sdist
31 run: pipx run build --sdist
32 - name: Check metadata
33 run: pipx run twine check dist/*.tar.gz
34 - uses: actions/upload-artifact@v5
35 with:
36 path: dist/*.tar.gz
37 name: sdist
38
39 build_wheels:
40 name: ${{ matrix.type }} ${{ matrix.arch }} on ${{ matrix.os }}
41 runs-on: ${{ matrix.os }}
42 defaults:
43 run:
44 shell: bash
45 strategy:
46 fail-fast: false
47 matrix:
48 # macos-15-intel for x86_64 wheels, macos-latest (arm64) handled in include
49 os: [macos-15-intel, windows-latest]
50 arch: [auto64]
51 build: ["*"]
52 skip: ["cp38-* cp39-* cp314t-* pp*"]
53 include:
54 # manylinux2014 for x86_64
55 - os: ubuntu-latest
56 arch: auto64
57 type: manylinux2014
58 build: "cp310-manylinux* cp311-manylinux* cp312-manylinux* cp313-manylinux* cp314-manylinux* pp311-manylinux*"
59 CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
60 CIBW_MANYLINUX_I686_IMAGE: manylinux2014
61 # native arm64 Linux runner
62 - os: ubuntu-24.04-arm
63 arch: aarch64
64 type: manylinux2014
65 build: "cp310-manylinux* cp311-manylinux* cp312-manylinux* cp313-manylinux* cp314-manylinux* pp311-manylinux*"
66
67 - os: macos-latest
68 arch: universal2
69 build: "*"
70 skip: "cp38-* cp39-* cp314t-* pp*"
71
72 - os: windows-latest
73 arch: auto32
74 build: "*"
75 skip: "cp38-* cp39-* cp314t-* pp*"
76 steps:
77 - uses: actions/checkout@v6
78 with:
79 submodules: recursive
80 fetch-depth: 0
81 - name: Set up Python
82 uses: actions/setup-python@v6
83 with:
84 python-version: "3.x"
85 - name: Install dependencies
86 run: pip install cibuildwheel
87 - name: Build Wheels
88 run: python -m cibuildwheel --output-dir wheelhouse .
89 env:
90 CIBW_BUILD: ${{ matrix.build }}
91 CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.CIBW_MANYLINUX_I686_IMAGE }}
92 CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.CIBW_MANYLINUX_X86_64_IMAGE }}
93 CIBW_ARCHS: ${{ matrix.arch }}
94 CIBW_SKIP: ${{ matrix.skip }}
95 - uses: actions/upload-artifact@v5
96 with:
97 path: wheelhouse/*.whl
98 name: wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.type }}
99
100 deploy:
101 name: Upload if tagged commit
102 if: startsWith(github.ref, 'refs/tags/')
103 # but only if all build jobs completed successfully
104 needs: [build_wheels, build_sdist]
105 runs-on: ubuntu-latest
106 permissions:
107 contents: write
108 id-token: write
109
110 steps:
111 - uses: actions/checkout@v6
112 - uses: actions/download-artifact@v6
113 with:
114 path: dist
115 merge-multiple: true
116
117 - name: Extract release notes from annotated tag message
118 id: release_notes
119 env:
120 # e.g. 0.1.0a1, 1.2.0b2 or 2.3.0rc3, but not 1.0.0
121 PRERELEASE_TAG_PATTERN: "[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+([ab]|rc)[[:digit:]]+"
122 run: |
123 # GH checkout action doesn't preserve tag annotations, we must fetch them
124 # https://github.com/actions/checkout/issues/290
125 git fetch --tags --force
126 # strip leading 'refs/tags/' to get the tag name
127 TAG_NAME="${GITHUB_REF##*/}"
128 # Dump tag message to temporary .md file (excluding the PGP signature at the bottom)
129 TAG_MESSAGE=$(git tag -l --format='%(contents)' $TAG_NAME | sed -n '/-----BEGIN PGP SIGNATURE-----/q;p')
130 echo "$TAG_MESSAGE" > "${{ runner.temp }}/release_notes.md"
131 # if the tag has a pre-release suffix mark the Github Release accordingly
132 if egrep -q "$PRERELEASE_TAG_PATTERN" <<< "$TAG_NAME"; then
133 echo "Tag contains a pre-release suffix"
134 echo "IS_PRERELEASE=true" >> "$GITHUB_ENV"
135 else
136 echo "Tag does not contain pre-release suffix"
137 echo "IS_PRERELEASE=false" >> "$GITHUB_ENV"
138 fi
139
140 - name: Create GitHub release
141 id: create_release
142 uses: softprops/action-gh-release@v2
143 with:
144 body_path: "${{ runner.temp }}/release_notes.md"
145 draft: false
146 prerelease: ${{ env.IS_PRERELEASE }}
147
148 - uses: pypa/[email protected]