diff --git a/tests/files/test_github_workflows.py b/tests/files/test_github_workflows.py index ebf2dcd..f3bdf33 100644 --- a/tests/files/test_github_workflows.py +++ b/tests/files/test_github_workflows.py @@ -83,3 +83,13 @@ def test_whenProjectIsGenerated_expectReleaseCreatedOnVersionTags( assert ' - "v*"\n' in content assert "GH_TOKEN: ${{ github.token }}" in content assert 'gh release create "$GITHUB_REF_NAME" dist/* ' in content + + +def test_whenProjectIsGenerated_expectReleaseFilesAttested(generate: Generate) -> None: + content = read_workflow(generate(), "release.yml") + + assert " artifact-metadata: write\n" in content + assert " attestations: write\n" in content + assert " id-token: write\n" in content + assert " uses: actions/attest@" in content + assert " subject-path: dist/*\n" in content diff --git a/{{cookiecutter.artifact}}/.github/workflows/release.yml b/{{cookiecutter.artifact}}/.github/workflows/release.yml index c9f1dd3..b2af3f3 100644 --- a/{{cookiecutter.artifact}}/.github/workflows/release.yml +++ b/{{cookiecutter.artifact}}/.github/workflows/release.yml @@ -19,7 +19,10 @@ jobs: needs: [build, sbom] runs-on: ubuntu-latest permissions: + artifact-metadata: write + attestations: write contents: write + id-token: write steps: - uses: actions/download-artifact@v8 @@ -27,6 +30,11 @@ jobs: path: dist merge-multiple: true + - name: Attest build provenance + uses: actions/attest@v4 + with: + subject-path: dist/* + - name: Create release env: GH_TOKEN: {% raw %}${{ github.token }}{% endraw %}