mirror of https://github.com/kubevela/kubevela.git
feat: add signed releases, SBOMs, and SLSA provenance (#6749)
- Add SPDX SBOMs for Vela Core and CLI images - Sign and attest images to GHCR and DockerHub - Generate and attest SLSA provenance - Include SBOMs for binaries via GoReleaser - Sign artifact checksums for integrity Signed-off-by: Ayush <ayushshyam.official.888@gmail.com>
This commit is contained in:
parent
f9e15c55ad
commit
d93e292142
|
@ -5,28 +5,41 @@ on:
|
|||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "v*"
|
||||
- 'v*'
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
publish-core-images:
|
||||
publish-vela-images:
|
||||
name: Build and Push Vela Images
|
||||
permissions:
|
||||
packages: write
|
||||
id-token: write
|
||||
attestations: write
|
||||
contents: write
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
vela_core_image: ${{ steps.meta-vela-core.outputs.image }}
|
||||
vela_core_digest: ${{ steps.meta-vela-core.outputs.digest }}
|
||||
vela_core_dockerhub_image: ${{ steps.meta-vela-core.outputs.dockerhub_image }}
|
||||
vela_cli_image: ${{ steps.meta-vela-cli.outputs.image }}
|
||||
vela_cli_digest: ${{ steps.meta-vela-cli.outputs.digest }}
|
||||
vela_cli_dockerhub_image: ${{ steps.meta-vela-cli.outputs.dockerhub_image }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.1
|
||||
|
||||
- name: Get the version
|
||||
- name: Install Crane
|
||||
uses: imjasonh/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # v0.1
|
||||
|
||||
- name: Install Cosign
|
||||
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # main
|
||||
with:
|
||||
cosign-release: 'v2.5.0'
|
||||
|
||||
- name: Get the image version
|
||||
id: get_version
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
|
@ -55,13 +68,16 @@ jobs:
|
|||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
|
||||
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
|
||||
with:
|
||||
driver-opts: image=moby/buildkit:master
|
||||
|
||||
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
|
||||
name: Build & Push Vela Core for Dockerhub, GHCR
|
||||
- name: Build & Push Vela Core for Dockerhub, GHCR
|
||||
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
|
@ -77,21 +93,48 @@ jobs:
|
|||
tags: |
|
||||
docker.io/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- uses: imjasonh/setup-crane@v0.1
|
||||
name: Installs Crane
|
||||
|
||||
|
||||
- name: Get Vela Core Image Digest
|
||||
id: meta-vela-core
|
||||
run: |
|
||||
IMAGE=ghcr.io/${{ github.repository_owner }}/oamdev/vela-core
|
||||
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/oamdev/vela-core
|
||||
DOCKER_IMAGE=docker.io/oamdev/vela-core
|
||||
TAG=${{ steps.get_version.outputs.VERSION }}
|
||||
DIGEST=$(crane digest $IMAGE:$TAG)
|
||||
echo "image=$IMAGE" >> $GITHUB_OUTPUT
|
||||
|
||||
DIGEST=$(crane digest $GHCR_IMAGE:$TAG)
|
||||
|
||||
echo "image=$GHCR_IMAGE" >> $GITHUB_OUTPUT
|
||||
echo "dockerhub_image=$DOCKER_IMAGE" >> $GITHUB_OUTPUT
|
||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
|
||||
name: Build & Push Vela CLI for Dockerhub, GHCR
|
||||
- name: Generate SBOM for Vela Core Image
|
||||
id: generate_vela_core_sbom
|
||||
uses: anchore/sbom-action@v0.17.0
|
||||
with:
|
||||
image: ghcr.io/${{ github.repository_owner }}/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
registry-username: ${{ github.actor }}
|
||||
registry-password: ${{ secrets.GITHUB_TOKEN }}
|
||||
format: spdx-json
|
||||
artifact-name: sbom-vela-core.spdx.json
|
||||
output-file: ${{ github.workspace }}/sbom-vela-core.spdx.json
|
||||
|
||||
- name: Sign Vela Core Image and Attest SBOM
|
||||
env:
|
||||
COSIGN_EXPERIMENTAL: 'true'
|
||||
run: |
|
||||
echo "signing vela core images..."
|
||||
cosign sign --yes ghcr.io/${{ github.repository_owner }}/oamdev/vela-core@${{ steps.meta-vela-core.outputs.digest }}
|
||||
cosign sign --yes docker.io/oamdev/vela-core@${{ steps.meta-vela-core.outputs.digest }}
|
||||
|
||||
echo "attesting SBOM against the vela core image..."
|
||||
cosign attest --yes --predicate ${{ github.workspace }}/sbom-vela-core.spdx.json --type spdx \
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-core@${{ steps.meta-vela-core.outputs.digest }}
|
||||
|
||||
cosign attest --yes --predicate ${{ github.workspace }}/sbom-vela-core.spdx.json --type spdx \
|
||||
docker.io/oamdev/vela-core@${{ steps.meta-vela-core.outputs.digest }}
|
||||
|
||||
- name: Build & Push Vela CLI for Dockerhub, GHCR
|
||||
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.cli
|
||||
|
@ -111,16 +154,58 @@ jobs:
|
|||
- name: Get Vela CLI Image Digest
|
||||
id: meta-vela-cli
|
||||
run: |
|
||||
IMAGE=ghcr.io/${{ github.repository_owner }}/oamdev/vela-cli
|
||||
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/oamdev/vela-cli
|
||||
DOCKER_IMAGE=docker.io/oamdev/vela-cli
|
||||
TAG=${{ steps.get_version.outputs.VERSION }}
|
||||
DIGEST=$(crane digest $IMAGE:$TAG)
|
||||
echo "image=$IMAGE" >> $GITHUB_OUTPUT
|
||||
|
||||
DIGEST=$(crane digest $GHCR_IMAGE:$TAG)
|
||||
|
||||
echo "image=$GHCR_IMAGE" >> $GITHUB_OUTPUT
|
||||
echo "dockerhub_image=$DOCKER_IMAGE" >> $GITHUB_OUTPUT
|
||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
||||
|
||||
provenance-vela-core:
|
||||
name: Generate Provenance for Vela Core
|
||||
needs: publish-core-images
|
||||
- name: Generate SBOM for Vela CLI Image
|
||||
id: generate_sbom
|
||||
uses: anchore/sbom-action@v0.17.0
|
||||
with:
|
||||
image: ghcr.io/${{ github.repository_owner }}/oamdev/vela-cli:${{ steps.get_version.outputs.VERSION }}
|
||||
registry-username: ${{ github.actor }}
|
||||
registry-password: ${{ secrets.GITHUB_TOKEN }}
|
||||
format: spdx-json
|
||||
artifact-name: sbom-vela-cli.spdx.json
|
||||
output-file: ${{ github.workspace }}/sbom-vela-cli.spdx.json
|
||||
|
||||
- name: Sign Vela CLI Image and Attest SBOM
|
||||
env:
|
||||
COSIGN_EXPERIMENTAL: 'true'
|
||||
run: |
|
||||
echo "signing vela CLI images..."
|
||||
cosign sign --yes ghcr.io/${{ github.repository_owner }}/oamdev/vela-cli@${{ steps.meta-vela-cli.outputs.digest }}
|
||||
cosign sign --yes docker.io/oamdev/vela-cli@${{ steps.meta-vela-cli.outputs.digest }}
|
||||
|
||||
echo "attesting SBOM against the vela cli image..."
|
||||
cosign attest --yes --predicate ${{ github.workspace }}/sbom-vela-cli.spdx.json --type spdx \
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-cli@${{ steps.meta-vela-cli.outputs.digest }}
|
||||
|
||||
cosign attest --yes --predicate ${{ github.workspace }}/sbom-vela-cli.spdx.json --type spdx \
|
||||
docker.io/oamdev/vela-cli@${{ steps.meta-vela-cli.outputs.digest }}
|
||||
|
||||
- name: Publish SBOMs as release artifacts
|
||||
uses: anchore/sbom-action/publish-sbom@v0.17.0
|
||||
|
||||
provenance-ghcr:
|
||||
name: Generate and Push Provenance to GCHR
|
||||
needs: publish-vela-images
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: 'Vela Core Image'
|
||||
image: ${{ needs.publish-vela-images.outputs.vela_core_image }}
|
||||
digest: ${{ needs.publish-vela-images.outputs.vela_core_digest }}
|
||||
- name: 'Vela CLI Image'
|
||||
image: ${{ needs.publish-vela-images.outputs.vela_cli_image }}
|
||||
digest: ${{ needs.publish-vela-images.outputs.vela_cli_digest }}
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
|
@ -128,25 +213,34 @@ jobs:
|
|||
packages: write
|
||||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0 # has to be sem var
|
||||
with:
|
||||
image: ${{ needs.publish-core-images.outputs.vela_core_image }}
|
||||
digest: ${{ needs.publish-core-images.outputs.vela_core_digest }}
|
||||
image: ${{ matrix.image }}
|
||||
digest: ${{ matrix.digest }}
|
||||
registry-username: ${{ github.actor }}
|
||||
secrets:
|
||||
registry-password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
provenance-vela-cli:
|
||||
name: Generate Provenance for Vela CLI
|
||||
needs: publish-core-images
|
||||
provenance-dockerhub:
|
||||
name: Generate and Push Provenance to DockerHub
|
||||
needs: publish-vela-images
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: 'Vela Core Image'
|
||||
image: ${{ needs.publish-vela-images.outputs.vela_core_dockerhub_image }}
|
||||
digest: ${{ needs.publish-vela-images.outputs.vela_core_digest }}
|
||||
- name: 'Vela CLI Image'
|
||||
image: ${{ needs.publish-vela-images.outputs.vela_cli_dockerhub_image }}
|
||||
digest: ${{ needs.publish-vela-images.outputs.vela_cli_digest }}
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
actions: read
|
||||
packages: write
|
||||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0 # has to be sem var
|
||||
actions: read
|
||||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
|
||||
with:
|
||||
image: ${{ needs.publish-core-images.outputs.vela_cli_image }}
|
||||
digest: ${{ needs.publish-core-images.outputs.vela_cli_digest }}
|
||||
registry-username: ${{ github.actor }}
|
||||
image: ${{ matrix.image }}
|
||||
digest: ${{ matrix.digest }}
|
||||
registry-username: oamdev
|
||||
secrets:
|
||||
registry-password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry-password: ${{ secrets.DOCKER_PASSWORD }}
|
|
@ -40,6 +40,14 @@ jobs:
|
|||
go-version: 1.22
|
||||
cache: true
|
||||
|
||||
- name: Install Cosign
|
||||
uses: sigstore/cosign-installer@main
|
||||
with:
|
||||
cosign-release: 'v2.5.0'
|
||||
|
||||
- name: Install syft
|
||||
uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
|
||||
with:
|
||||
|
|
|
@ -31,6 +31,28 @@ builds:
|
|||
ldflags:
|
||||
- -s -w -X github.com/oam-dev/kubevela/version.VelaVersion={{ .Version }} -X github.com/oam-dev/kubevela/version.GitRevision=git-{{.ShortCommit}}
|
||||
|
||||
sboms:
|
||||
- id: kubevela-binaries-sboms
|
||||
artifacts: binary
|
||||
documents:
|
||||
- "${artifact}-{{ .Version }}-{{ .Os }}-{{ .Arch }}.spdx.sbom.json"
|
||||
|
||||
signs:
|
||||
- id: kubevela-cosign-keyless
|
||||
artifacts: checksum # sign the checksum file over individual artifacts
|
||||
signature: "${artifact}-keyless.sig"
|
||||
certificate: "${artifact}-keyless.pem"
|
||||
cmd: cosign
|
||||
args:
|
||||
- "sign-blob"
|
||||
- "--yes"
|
||||
- "--output-signature"
|
||||
- "${artifact}-keyless.sig"
|
||||
- "--output-certificate"
|
||||
- "${artifact}-keyless.pem"
|
||||
- "${artifact}"
|
||||
output: true
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
id: vela-cli-tgz
|
||||
|
|
Loading…
Reference in New Issue