Skip to content

Commit 3f0d4b3

Browse files
authored
Support SLSA Provenance (#118)
* fix: Docker image runs as root * chore: remove scorecard.yml * feat: support publish provenance * feat: add SLSA badge
1 parent d11b480 commit 3f0d4b3

File tree

5 files changed

+36
-75
lines changed

5 files changed

+36
-75
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
name: "commit-check_docs"
100100
path: ${{ github.workspace }}/docs/_build/html
101101

102-
- name: Upload to github pages
102+
- name: Upload docs to github pages
103103
# only publish doc changes from main branch
104104
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
105105
uses: peaceiris/actions-gh-pages@v3

.github/workflows/publish-package.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ on:
44
release:
55
branches: [main]
66
types: [published]
7+
workflow_dispatch:
78

89
jobs:
910
publish:
1011
runs-on: ubuntu-latest
12+
outputs:
13+
hash: ${{ steps.hash.outputs.hash }}
1114
steps:
1215
- uses: actions/checkout@v4
1316
# use fetch --all for setuptools_scm to work
@@ -27,6 +30,17 @@ jobs:
2730
# Check distribution
2831
twine check dist/commit_check*
2932
33+
# Generate hashes used for provenance.
34+
- name: Generate hash
35+
id: hash
36+
run: |
37+
cd dist
38+
HASHES=$(sha256sum * | base64 -w0)
39+
echo "hashes=$HASHES" >> "$GITHUB_OUTPUT"
40+
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
41+
with:
42+
path: ./dist
43+
3044
- name: Publish package to TestPyPI
3145
if: github.event_name == 'workflow_dispatch' && github.repository == 'commit-check/commit-check'
3246
env:
@@ -41,3 +55,16 @@ jobs:
4155
TWINE_USERNAME: __token__
4256
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
4357
run: twine upload dist/commit_check*
58+
59+
provenance:
60+
needs: ['publish']
61+
permissions:
62+
actions: read # To read the workflow path.
63+
id-token: write # To sign the provenance.
64+
contents: write # To add assets to a release.
65+
# Can't pin with hash due to how this workflow works.
66+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.9.0
67+
with:
68+
base64-subjects: ${{ needs.build.outputs.hash }}
69+
upload-assets: true # Optional: Upload to a new release
70+
continue-on-error: true

.github/workflows/scorecard.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.12-slim
22

3-
ARG VERSION==""
3+
ARG VERSION
44

55
LABEL com.github.actions.name="Commit Check"
66
LABEL com.github.actions.description="Check commit message formatting, branch naming, commit author, email, and more."
@@ -10,10 +10,12 @@ LABEL com.github.actions.color="gray-dark"
1010
LABEL repository="https://github.com/commit-check/commit-check"
1111
LABEL maintainer="shenxianpeng <20297606+shenxianpeng@users.noreply.github.com>"
1212

13-
RUN if [ -z "${VERSION}" ]; then \
13+
RUN if [ -z "$VERSION" ]; then \
1414
pip3 install commit-check; \
1515
else \
1616
pip3 install commit-check==$VERSION; \
1717
fi
1818

19+
USER nobody
20+
1921
ENTRYPOINT [ "commit-check" ]

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Commit Check
2121
:target: https://github.com/commit-check/commit-check
2222
:alt: commit-check
2323

24+
.. image:: https://slsa.dev/images/gh-badge-level3.svg
25+
:target: https://slsa.dev
26+
:alt: SLSA
27+
2428
Overview
2529
--------
2630

0 commit comments

Comments
 (0)