diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1918e23..3ce25d5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,6 +5,10 @@ on: branches: [main] pull_request: +# Least privilege: jobs only read the repo. +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest @@ -16,6 +20,8 @@ jobs: - "3.13" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: diff --git a/template/.github/workflows/ci.yaml b/template/.github/workflows/ci.yaml index 1fb9560..5418702 100644 --- a/template/.github/workflows/ci.yaml +++ b/template/.github/workflows/ci.yaml @@ -6,6 +6,10 @@ on: pull_request: workflow_call: +# Least privilege: jobs only read the repo. +permissions: + contents: read + jobs: lint: strategy: @@ -18,6 +22,8 @@ jobs: runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -44,6 +50,8 @@ jobs: - "3.13" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -58,6 +66,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: diff --git a/template/.github/workflows/publish.yaml b/template/.github/workflows/publish.yaml index f4f9bd7..9bbf316 100644 --- a/template/.github/workflows/publish.yaml +++ b/template/.github/workflows/publish.yaml @@ -15,5 +15,6 @@ jobs: - name: Download release artifacts env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release download "${{ github.event.release.tag_name }}" --dir dist --repo "${{ github.repository }}" + TAG: ${{ github.event.release.tag_name }} + run: gh release download "$TAG" --dir dist --repo "$GITHUB_REPOSITORY" - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 diff --git a/template/.github/workflows/release.yaml b/template/.github/workflows/release.yaml index 4fca695..945cb2b 100644 --- a/template/.github/workflows/release.yaml +++ b/template/.github/workflows/release.yaml @@ -23,6 +23,10 @@ on: type: string default: "rc" +# Least privilege: read-only by default; the release job widens its own token. +permissions: + contents: read + jobs: ci: uses: ./.github/workflows/ci.yaml