Skip to content

Commit 0e1010a

Browse files
authored
Thank you Doctor Zizmor! (#81)
1 parent c9017d1 commit 0e1010a

File tree

4 files changed

+76
-10
lines changed

4 files changed

+76
-10
lines changed

.github/workflows/ci.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 0
26+
persist-credentials: false
2627

2728
- uses: hynek/build-and-inspect-python-package@v2
2829
id: baipp
@@ -56,11 +57,14 @@ jobs:
5657
- uses: hynek/setup-cached-uv@v2
5758

5859
- name: Prepare & run Nox
60+
env:
61+
PYTHON: ${{ matrix.python-version }}
62+
5963
run: >
6064
uvx
6165
--with "tomli; python_version<'3.11'"
6266
nox
63-
--python ${{ matrix.python-version }}
67+
--python $PYTHON
6468
--sessions tests
6569
-- --installpkg dist/*.whl
6670
@@ -80,6 +84,8 @@ jobs:
8084

8185
steps:
8286
- uses: actions/checkout@v4
87+
with:
88+
persist-credentials: false
8389
- uses: actions/setup-python@v5
8490
with:
8591
python-version-file: .python-version-default
@@ -118,6 +124,8 @@ jobs:
118124
fail-fast: false
119125
matrix:
120126
python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }}
127+
env:
128+
PYTHON: ${{ matrix.python-version }}
121129

122130
steps:
123131
- name: Download pre-built packages
@@ -137,15 +145,15 @@ jobs:
137145
uvx
138146
--with "tomli; python_version<'3.11'"
139147
nox
140-
--python ${{ matrix.python-version }}
148+
--python $PYTHON
141149
--sessions mypy_api
142150
143151
- name: Check using Pyright
144152
run: >
145153
uvx
146154
--with "tomli; python_version<'3.11'"
147155
nox
148-
--python ${{ matrix.python-version }}
156+
--python $PYTHON
149157
--sessions pyright_api
150158
151159
mypy-pkg:
@@ -197,6 +205,8 @@ jobs:
197205

198206
steps:
199207
- uses: actions/checkout@v4
208+
with:
209+
persist-credentials: false
200210
- uses: actions/setup-python@v5
201211
with:
202212
python-version-file: .python-version-default

.github/workflows/codeql-analysis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ jobs:
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
2830

2931
- name: Initialize CodeQL
3032
uses: github/codeql-action/init@v3
3133
with:
3234
languages: ${{ matrix.language }}
3335

36+
- name: Autobuild
37+
uses: github/codeql-action/autobuild@v3
38+
3439
- name: Perform CodeQL Analysis
3540
uses: github/codeql-action/analyze@v3

.github/workflows/pypi-package.yml

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Build & maybe upload PyPI package
2+
name: Build & upload PyPI package
33

44
on:
55
push:
@@ -10,32 +10,38 @@ on:
1010
- published
1111
workflow_dispatch:
1212

13-
permissions:
14-
attestations: write
15-
contents: read
16-
id-token: write
1713

1814
jobs:
15+
# Always build & lint package.
1916
build-package:
2017
name: Build & verify package
2118
runs-on: ubuntu-latest
19+
permissions:
20+
attestations: write
21+
id-token: write
2222

2323
steps:
2424
- uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
27+
persist-credentials: false
2728

2829
- uses: hynek/build-and-inspect-python-package@v2
2930
with:
3031
attest-build-provenance-github: 'true'
3132

33+
34+
# Upload to Test PyPI on every commit on main.
3235
release-test-pypi:
3336
name: Publish in-dev package to test.pypi.org
3437
environment: release-test-pypi
35-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
38+
if: github.repository_owner == 'hynek' && github.event_name == 'push' && github.ref == 'refs/heads/main'
3639
runs-on: ubuntu-latest
3740
needs: build-package
3841

42+
permissions:
43+
id-token: write
44+
3945
steps:
4046
- name: Download packages built by build-and-inspect-python-package
4147
uses: actions/download-artifact@v4
@@ -46,16 +52,21 @@ jobs:
4652
- name: Upload package to Test PyPI
4753
uses: pypa/gh-action-pypi-publish@release/v1
4854
with:
55+
attestations: true
4956
repository-url: https://test.pypi.org/legacy/
5057

58+
5159
# Upload to real PyPI on GitHub Releases.
5260
release-pypi:
5361
name: Publish released package to pypi.org
5462
environment: release-pypi
55-
if: github.event.action == 'published'
63+
if: github.repository_owner == 'hynek' && github.event.action == 'published'
5664
runs-on: ubuntu-latest
5765
needs: build-package
5866

67+
permissions:
68+
id-token: write
69+
5970
steps:
6071
- name: Download packages built by build-and-inspect-python-package
6172
uses: actions/download-artifact@v4
@@ -65,3 +76,5 @@ jobs:
6576

6677
- name: Upload package to PyPI
6778
uses: pypa/gh-action-pypi-publish@release/v1
79+
with:
80+
attestations: true

.github/workflows/zizmor.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# https://github.com/woodruffw/zizmor
2+
name: GitHub Actions Security Analysis with Zizmor
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["*"]
9+
10+
permissions:
11+
contents: read
12+
13+
14+
jobs:
15+
zizmor:
16+
name: Zizmor latest via Cargo
17+
runs-on: ubuntu-latest
18+
permissions:
19+
security-events: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
25+
- name: Setup Rust
26+
uses: actions-rust-lang/setup-rust-toolchain@v1
27+
- name: Get zizmor
28+
run: cargo install zizmor
29+
- name: Run zizmor
30+
run: zizmor --format sarif . > results.sarif
31+
- name: Upload SARIF file
32+
uses: github/codeql-action/upload-sarif@v3
33+
with:
34+
# Path to SARIF file relative to the root of the repository
35+
sarif_file: results.sarif
36+
# Optional category for the results
37+
# Used to differentiate multiple results for one commit
38+
category: zizmor

0 commit comments

Comments
 (0)