Skip to content

Commit e99aabb

Browse files
authored
ci: secure GitHub Actions workflows (#350)
1 parent d00138f commit e99aabb

3 files changed

Lines changed: 46 additions & 23 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ updates:
99
actions:
1010
patterns:
1111
- "*"
12+
cooldown:
13+
default-days: 7
1214

1315
# Maintain dependencies for pip constraints-ci.txt
1416
- package-ecosystem: "pip"
@@ -18,3 +20,5 @@ updates:
1820
allow:
1921
- dependency-name: "cmake"
2022
- dependency-name: "ninja"
23+
cooldown:
24+
default-days: 7

.github/workflows/build.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ concurrency:
2020
env:
2121
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.overrideVersion }}
2222

23+
permissions: {}
24+
2325
jobs:
2426
lint:
2527
name: Lint
2628
runs-on: ubuntu-latest
2729
steps:
28-
- uses: actions/checkout@v7
29-
- uses: actions/setup-python@v6
30+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
31+
with:
32+
persist-credentials: false
33+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3034
with:
3135
python-version: "3.x"
32-
- uses: pre-commit/action@v3.0.1
36+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
3337

3438

3539
build_wheels:
@@ -76,26 +80,27 @@ jobs:
7680
arch: "universal2"
7781

7882
steps:
79-
- uses: actions/checkout@v7
83+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
8084
with:
8185
fetch-depth: 0 # required for setuptools_scm to find tags
8286
submodules: 'recursive'
87+
persist-credentials: false
8388

8489
- name: Set up QEMU
85-
uses: docker/setup-qemu-action@v4.1.0
90+
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
8691
if: runner.os == 'Linux' && runner.arch == 'X64'
8792

88-
- uses: astral-sh/setup-uv@v8.2.0
93+
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
8994
with:
9095
enable-cache: false
9196

9297
- name: Build wheels
93-
uses: pypa/cibuildwheel@v4.1
98+
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
9499
env:
95100
CIBW_ARCHS: "${{ matrix.arch }}"
96101
CIBW_BUILD: "cp39-${{ matrix.build }}*"
97102

98-
- uses: actions/upload-artifact@v7
103+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
99104
with:
100105
name: cibw-wheels-${{ matrix.os }}-${{ matrix.build }}${{ matrix.arch }}
101106
path: ./wheelhouse/*.whl
@@ -113,15 +118,16 @@ jobs:
113118
needs: [lint]
114119
runs-on: ubuntu-latest
115120
steps:
116-
- uses: actions/checkout@v7
121+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
117122
with:
118123
fetch-depth: 0 # required for setuptools_scm to find tags
119124
submodules: 'recursive'
125+
persist-credentials: false
120126

121127
- name: Build SDist
122128
run: pipx run build --sdist
123129

124-
- uses: actions/upload-artifact@v7
130+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
125131
with:
126132
name: cibw-sdist
127133
path: dist/*.tar.gz
@@ -136,24 +142,28 @@ jobs:
136142
python: ["3.8", "3.13"]
137143

138144
steps:
139-
- uses: actions/checkout@v7
140-
- uses: actions/setup-python@v6
145+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
146+
with:
147+
persist-credentials: false
148+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
141149
name: Install Python ${{ matrix.python }}
142150
id: python
143151
with:
144152
python-version: ${{ matrix.python }}
145153
update-environment: false
146154

147-
- uses: astral-sh/setup-uv@v8.2.0
155+
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
148156
with:
149157
enable-cache: false
150158

151159
- name: Setup environment
152160
run: |
153-
uv venv --python "${{ steps.python.outputs.python-path }}"
161+
uv venv --python "${STEPS_PYTHON_OUTPUTS_PYTHON_PATH}"
154162
uv pip install pip --group test
163+
env:
164+
STEPS_PYTHON_OUTPUTS_PYTHON_PATH: ${{ steps.python.outputs.python-path }}
155165

156-
- uses: actions/download-artifact@v8
166+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
157167
with:
158168
name: cibw-sdist
159169
path: sdist
@@ -185,7 +195,7 @@ jobs:
185195
needs: [build_wheels, build_sdist, test_sdist]
186196
runs-on: ubuntu-latest
187197
steps:
188-
- uses: actions/download-artifact@v8
198+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
189199
with:
190200
pattern: cibw-*
191201
path: dist
@@ -203,12 +213,15 @@ jobs:
203213
url: https://pypi.org/p/ninja
204214
permissions:
205215
id-token: write
216+
attestations: write
206217
steps:
207-
- uses: actions/download-artifact@v8
218+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
208219
with:
209220
pattern: cibw-*
210221
path: dist
211222
merge-multiple: true
212223

213224
- name: Upload to PyPI
214-
uses: pypa/gh-action-pypi-publish@release/v1
225+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
226+
with:
227+
attestations: true

.pre-commit-config.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v6.0.0
3+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-case-conflict
@@ -13,27 +13,33 @@ repos:
1313
- id: trailing-whitespace
1414

1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: "v0.15.17"
16+
rev: "77039ccbba72c8aede339c5f8ae29b42aced0a2e" # frozen: v0.15.18
1717
hooks:
1818
- id: ruff
1919
args: [--fix, --show-fixes]
2020

2121
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: "v2.1.0"
22+
rev: "d2823d321df3af8f878f7ee3414dc94d037145b9" # frozen: v2.1.0
2323
hooks:
2424
- id: mypy
2525
files: src
2626
args: []
2727

2828
- repo: https://github.com/abravalheri/validate-pyproject
29-
rev: "v0.25"
29+
rev: "4b2e70d08cb2ccd26d1fba73588de41c7a5d50b7" # frozen: v0.25
3030
hooks:
3131
- id: validate-pyproject
3232
additional_dependencies: ["validate-pyproject-schema-store[all]>=2024.10.21"]
3333

3434
- repo: https://github.com/python-jsonschema/check-jsonschema
35-
rev: "0.37.3"
35+
rev: "8ef330cbb7204d388aa7a620f9549bcea8009663" # frozen: 0.37.3
3636
hooks:
3737
- id: check-dependabot
3838
- id: check-github-workflows
3939
- id: check-readthedocs
40+
41+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
42+
rev: e3eebf65325ccc992422292cb7a4baee967cf815 # frozen: v1.26.1
43+
hooks:
44+
- id: zizmor
45+
files: "^\\.github"

0 commit comments

Comments
 (0)