1
+ name : Tests
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ tags :
8
+ - ' *'
9
+ pull_request : ~
10
+
11
+ concurrency :
12
+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13
+ cancel-in-progress : true
14
+
15
+ jobs :
16
+ generate-test-matrix :
17
+ name : Generate test matrix
18
+ runs-on : ubuntu-latest
19
+ outputs :
20
+ folders : ${{ steps.get-folders.outputs.folders }}
21
+ steps :
22
+ - name : Check out code from Github
23
+ uses : actions/checkout@v4
24
+ - name : Get folders with tests
25
+ id : get-folders
26
+ run : |
27
+ FOLDERS=$(find . -maxdepth 2 -type d -name 'tests' ! -path '*/distutils/*' \
28
+ | cut -d "/" -f2 | sort -u \
29
+ | jq -Rsc 'split("\n") | map( select(length > 0) )')
30
+ echo "folders: ${FOLDERS}"
31
+ echo "folders=${FOLDERS}" >> $GITHUB_OUTPUT
32
+
33
+ build :
34
+ name : Run build
35
+ runs-on : ubuntu-latest
36
+ needs : [generate-test-matrix]
37
+ strategy :
38
+ fail-fast : false
39
+ matrix :
40
+ folder : ${{ fromJson(needs.generate-test-matrix.outputs.folders) }}
41
+ version : ["3.13"]
42
+ steps :
43
+ - name : Check out code from Github
44
+ uses : actions/checkout@v4
45
+ - name : Set up Python
46
+ uses : actions/setup-python@v5
47
+ with :
48
+ python-version : ${{ matrix.version }}
49
+ check-latest : true
50
+ - name : Run tests
51
+ run : |
52
+ cd ${{ matrix.folder }}
53
+ python -m build
54
+ - name : Upload packages
55
+ uses : actions/upload-artifact@v4
56
+ with :
57
+ name : dist-${{ matrix.folder }}
58
+ path : ${{ matrix.folder }}/dist
59
+
60
+ publish-to-pypi :
61
+ name : Release
62
+ runs-on : ubuntu-latest
63
+ if : ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
64
+ needs : [build]
65
+ permissions :
66
+ # Use to sign the release artifacts
67
+ id-token : write
68
+ # Used to upload release artifacts
69
+ contents : write
70
+ # Used to generate artifact attestation
71
+ attestations : write
72
+ steps :
73
+ - name : Download all the dists
74
+ uses : actions/download-artifact@v4
75
+ with :
76
+ name : python-package-distributions
77
+ path : dist/
78
+ - name : Publish distribution 📦 to PyPI
79
+ uses : pypa/gh-action-pypi-publish@release/v1
80
+
81
+
82
+ github-release :
83
+ name : >-
84
+ Sign the Python 🐍 distribution 📦 with Sigstore
85
+ and upload them to GitHub Release
86
+ needs :
87
+ - publish-to-pypi
88
+ runs-on : ubuntu-latest
89
+
90
+ permissions :
91
+ contents : write # IMPORTANT: mandatory for making GitHub Releases
92
+ id-token : write # IMPORTANT: mandatory for sigstore
93
+
94
+ steps :
95
+ - name : Download all the dists
96
+ uses : actions/download-artifact@v4
97
+ with :
98
+ name : python-package-distributions
99
+ path : dist/
100
+ - name : Sign the dists with Sigstore
101
+
102
+ with :
103
+ inputs : >-
104
+ ./dist/*.tar.gz
105
+ ./dist/*.whl
106
+ - name : Create GitHub Release
107
+ env :
108
+ GITHUB_TOKEN : ${{ github.token }}
109
+ run : >-
110
+ gh release create
111
+ '${{ github.ref_name }}'
112
+ --repo '${{ github.repository }}'
113
+ --notes ""
114
+ - name : Upload artifact signatures to GitHub Release
115
+ env :
116
+ GITHUB_TOKEN : ${{ github.token }}
117
+ # Upload to GitHub Release using the `gh` CLI.
118
+ # `dist/` contains the built packages, and the
119
+ # sigstore-produced signatures and certificates.
120
+ run : >-
121
+ gh release upload
122
+ '${{ github.ref_name }}' dist/**
123
+ --repo '${{ github.repository }}'
0 commit comments