Skip to content

Commit 3f8017e

Browse files
authored
Thank you Doctor Zizmor! (#225)
1 parent d3359c4 commit 3f8017e

File tree

6 files changed

+114
-14
lines changed

6 files changed

+114
-14
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333

3434
steps:
3535
- uses: actions/checkout@v4
36+
with:
37+
persist-credentials: false
3638
- uses: actions/setup-python@v5
3739
with:
3840
python-version: ${{ matrix.python-version }}
@@ -64,6 +66,8 @@ jobs:
6466

6567
steps:
6668
- uses: actions/checkout@v4
69+
with:
70+
persist-credentials: false
6771
- uses: actions/setup-python@v5
6872
with:
6973
python-version-file: .python-version-default
@@ -104,6 +108,8 @@ jobs:
104108

105109
steps:
106110
- uses: actions/checkout@v4
111+
with:
112+
persist-credentials: false
107113
- uses: actions/setup-python@v5
108114
with:
109115
python-version-file: .python-version-default
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: CodeQL
3+
4+
on:
5+
schedule:
6+
- cron: "30 22 * * 4"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [python]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
30+
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@v3
33+
with:
34+
languages: ${{ matrix.language }}
35+
36+
- name: Autobuild
37+
uses: github/codeql-action/autobuild@v3
38+
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v3

.github/workflows/pin-for-pyoxidizer.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ jobs:
1919

2020
env:
2121
BRANCH_NAME: auto-dependency-upgrades-${{ matrix.runs-on }}
22+
REF_NAME: ${{ github.ref_name }}
23+
RUNS_ON: ${{ matrix.runs-on}}
2224

2325
steps:
2426
- uses: actions/checkout@v4
27+
with:
28+
persist-credentials: false
2529
- uses: actions/setup-python@v5
2630
with:
2731
# Keep in-sync with ./pyoxidizer.yml
@@ -44,22 +48,24 @@ jobs:
4448
git config user.name github-actions
4549
git config user.email [email protected]
4650
git add .
47-
git commit -m "Automated dependency upgrades for ${{ matrix.runs-on}}"
48-
git push -f origin ${{ github.ref_name }}:${{ env.BRANCH_NAME }}
51+
git commit -m "Automated dependency upgrades for $RUNS_ON
52+
git push -f origin $REF_NAME:$BRANCH_NAME
4953
5054
- name: Open pull request if needed
5155
if: steps.changes.outputs.count > 0
5256
shell: bash
5357
env:
5458
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
RUN_ID: ${{ github.run_id }}
60+
REPO: ${{ github.repository }}
5561
# Only open a PR if the branch is not attached to an existing one
5662
run: |
57-
PR=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number -q '.[0].number')
63+
PR=$(gh pr list --head $BRANCH_NAME --json number -q '.[0].number')
5864
if [ -z $PR ]; then
5965
gh pr create \
60-
--head ${{ env.BRANCH_NAME }} \
61-
--title "Automated dependency upgrades for ${{ matrix.runs-on}}" \
62-
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
66+
--head $BRANCH_NAME \
67+
--title "Automated dependency upgrades for $RUNS_ON" \
68+
--body "Full log: https://github.com/$REPO/actions/runs/$RUN_ID"
6369
else
6470
echo "Pull request already exists, won't create a new one."
6571
fi

.github/workflows/pyoxidizer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
- uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 0 # get correct version
32+
persist-credentials: false
3233
- uses: actions/setup-python@v5
3334
with:
3435
# Double-check latest version supported by PyOxidizer:

.github/workflows/pypi-package.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
---
2-
name: Build & maybe upload PyPI package
2+
name: Build & upload PyPI package
33

44
on:
55
push:
66
branches: [main]
77
tags: ["*"]
8-
pull_request:
9-
branches: [main]
108
release:
119
types:
1210
- published
1311
workflow_dispatch:
1412

15-
permissions:
16-
contents: read
17-
id-token: write
1813

1914
jobs:
2015
# Always build & lint package.
2116
build-package:
2217
name: Build & verify package
2318
runs-on: ubuntu-latest
19+
permissions:
20+
attestations: write
21+
id-token: write
2422

2523
steps:
2624
- uses: actions/checkout@v4
2725
with:
2826
fetch-depth: 0
27+
persist-credentials: false
2928

3029
- uses: hynek/build-and-inspect-python-package@v2
30+
with:
31+
attest-build-provenance-github: 'true'
32+
3133

3234
# Upload to Test PyPI on every commit on main.
3335
release-test-pypi:
3436
name: Publish in-dev package to test.pypi.org
3537
environment: release-test-pypi
36-
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'
3739
runs-on: ubuntu-latest
3840
needs: build-package
3941

42+
permissions:
43+
id-token: write
44+
4045
steps:
4146
- name: Download packages built by build-and-inspect-python-package
4247
uses: actions/download-artifact@v4
@@ -49,14 +54,18 @@ jobs:
4954
with:
5055
repository-url: https://test.pypi.org/legacy/
5156

57+
5258
# Upload to real PyPI on GitHub Releases.
5359
release-pypi:
5460
name: Publish released package to pypi.org
5561
environment: release-pypi
56-
if: github.event.action == 'published'
62+
if: github.repository_owner == 'hynek' && github.event.action == 'published'
5763
runs-on: ubuntu-latest
5864
needs: build-package
5965

66+
permissions:
67+
id-token: write
68+
6069
steps:
6170
- name: Download packages built by build-and-inspect-python-package
6271
uses: actions/download-artifact@v4

.github/workflows/zizmor.yml

Lines changed: 38 additions & 0 deletions
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)