Generate provenance attestations for release artifacts and docker image (#3225)

Adding https://github.com/actions/attest-build-provenance to the ci builds so
that the release assets and docker image for the next release tag generate
signed build provenance attestations for workflow artifacts.
This commit is contained in:
lectrical authored and GitHub committed 2024-12-29 21:53:16 +09:00
1 parent 8bcdc9304a
commit bcbf2b4616
1 file changed
+20 -1
+20 -1
View File
@@ -294,6 +294,9 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
id-token: write
contents: read
attestations: write
packages: write packages: write
needs: linux needs: linux
steps: steps:
@@ -329,7 +332,8 @@ jobs:
id: metadata id: metadata
with: with:
images: ghcr.io/${{ github.repository }} images: ghcr.io/${{ github.repository }}
tags: ${{ startsWith(github.ref, 'refs/tags/jq-') tags: >
${{ startsWith(github.ref, 'refs/tags/jq-')
&& format('type=match,pattern=jq-(.*),group=1,value={0}', github.ref_name) && format('type=match,pattern=jq-(.*),group=1,value={0}', github.ref_name)
|| 'type=sha,format=long' }} || 'type=sha,format=long' }}
- name: Set up QEMU - name: Set up QEMU
@@ -344,6 +348,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and release Docker image - name: Build and release Docker image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
id: build-push
with: with:
context: . context: .
push: ${{ startsWith(github.ref, 'refs/tags/jq-') }} push: ${{ startsWith(github.ref, 'refs/tags/jq-') }}
@@ -351,11 +356,20 @@ jobs:
platforms: linux/386,linux/amd64,linux/arm64,linux/mips64le,linux/ppc64le,linux/riscv64,linux/s390x platforms: linux/386,linux/amd64,linux/arm64,linux/mips64le,linux/ppc64le,linux/riscv64,linux/s390x
tags: ${{ steps.metadata.outputs.tags }} tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }} labels: ${{ steps.metadata.outputs.labels }}
- name: Generate signed attestations
if: startsWith(github.ref, 'refs/tags/jq-')
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.build-push.outputs.digest }}
push-to-registry: true
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write
id-token: write
attestations: write
pull-requests: write pull-requests: write
environment: release environment: release
needs: [linux, macos, windows, dist, docker] needs: [linux, macos, windows, dist, docker]
@@ -366,6 +380,7 @@ jobs:
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
pattern: jq-*
merge-multiple: true merge-multiple: true
- name: Upload release - name: Upload release
env: env:
@@ -378,6 +393,10 @@ jobs:
sha256sum jq-* > sha256sum.txt sha256sum jq-* > sha256sum.txt
gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes
gh release upload "$TAG_NAME" --clobber jq-* sha256sum.txt gh release upload "$TAG_NAME" --clobber jq-* sha256sum.txt
- name: Generate signed attestations
uses: actions/attest-build-provenance@v2
with:
subject-path: jq-*
- name: Import GPG key - name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6 uses: crazy-max/ghaction-import-gpg@v6
with: with: