Skip to content

Commit

Permalink
Thank you Doctor Zizmor! (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek authored Nov 1, 2024
1 parent d3359c4 commit 3f8017e
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -64,6 +66,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .python-version-default
Expand Down Expand Up @@ -104,6 +108,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .python-version-default
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: CodeQL

on:
schedule:
- cron: "30 22 * * 4"

permissions:
contents: read

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [python]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

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

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
18 changes: 12 additions & 6 deletions .github/workflows/pin-for-pyoxidizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ jobs:

env:
BRANCH_NAME: auto-dependency-upgrades-${{ matrix.runs-on }}
REF_NAME: ${{ github.ref_name }}
RUNS_ON: ${{ matrix.runs-on}}

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
# Keep in-sync with ./pyoxidizer.yml
Expand All @@ -44,22 +48,24 @@ jobs:
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Automated dependency upgrades for ${{ matrix.runs-on}}"
git push -f origin ${{ github.ref_name }}:${{ env.BRANCH_NAME }}
git commit -m "Automated dependency upgrades for $RUNS_ON
git push -f origin $REF_NAME:$BRANCH_NAME
- name: Open pull request if needed
if: steps.changes.outputs.count > 0
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.run_id }}
REPO: ${{ github.repository }}
# Only open a PR if the branch is not attached to an existing one
run: |
PR=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number -q '.[0].number')
PR=$(gh pr list --head $BRANCH_NAME --json number -q '.[0].number')
if [ -z $PR ]; then
gh pr create \
--head ${{ env.BRANCH_NAME }} \
--title "Automated dependency upgrades for ${{ matrix.runs-on}}" \
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
--head $BRANCH_NAME \
--title "Automated dependency upgrades for $RUNS_ON" \
--body "Full log: https://github.com/$REPO/actions/runs/$RUN_ID"
else
echo "Pull request already exists, won't create a new one."
fi
1 change: 1 addition & 0 deletions .github/workflows/pyoxidizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # get correct version
persist-credentials: false
- uses: actions/setup-python@v5
with:
# Double-check latest version supported by PyOxidizer:
Expand Down
25 changes: 17 additions & 8 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
---
name: Build & maybe upload PyPI package
name: Build & upload PyPI package

on:
push:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
release:
types:
- published
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

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


# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
environment: release-test-pypi
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.repository_owner == 'hynek' && github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

permissions:
id-token: write

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
Expand All @@ -49,14 +54,18 @@ jobs:
with:
repository-url: https://test.pypi.org/legacy/


# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
environment: release-pypi
if: github.event.action == 'published'
if: github.repository_owner == 'hynek' && github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

permissions:
id-token: write

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# https://github.com/woodruffw/zizmor
name: GitHub Actions Security Analysis with Zizmor

on:
push:
branches: ["main"]
pull_request:
branches: ["*"]

permissions:
contents: read


jobs:
zizmor:
name: Zizmor latest via Cargo
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Get zizmor
run: cargo install zizmor
- name: Run zizmor
run: zizmor --format sarif . > results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
# Optional category for the results
# Used to differentiate multiple results for one commit
category: zizmor

0 comments on commit 3f8017e

Please sign in to comment.