ci: add yes option with cosign #17
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches-ignore: | |
- '**' | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
env: | |
COSIGN_EXPERIMENTAL: "1" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install cosign | |
uses: sigstore/cosign-installer@v3 | |
- name: Set env | |
run: echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Build and push | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
tags: | | |
ghcr.io/${{ github.repository }}:latest | |
ghcr.io/${{ github.repository }}:${{ env.TAG_VERSION }} | |
- name: Write signing key | |
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key | |
shell: bash | |
- name: Generate SBOM | |
uses: anchore/sbom-action@v0 | |
with: | |
image: ghcr.io/${{ github.repository }}:${{ env.TAG_VERSION }} | |
artifact-name: sbom.spdx.json | |
output-file: sbom.spdx.json | |
- name: Attach SBOM file in image | |
run: | | |
cosign attest --yes --key cosign.key --type spdx --predicate sbom.spdx.json ghcr.io/${{ github.repository }}:${{ env.TAG_VERSION }}@${{ steps.build-and-push.outputs.digest }} | |
cosign attest --yes --key cosign.key --type spdx --predicate sbom.spdx.json ghcr.io/${{ github.repository }}:latest@${{ steps.build-and-push.outputs.digest }} | |
shell: bash | |
- name: Published a signed image | |
env: | |
COSIGN_EXPERIMENTAL: "1" | |
run: | | |
cosign sign --yes --key cosign.key ghcr.io/${{ github.repository }}:${{ env.TAG_VERSION }}@${{ steps.build-and-push.outputs.digest }} | |
cosign sign --yes --key cosign.key ghcr.io/${{ github.repository }}:latest@${{ steps.build-and-push.outputs.digest }} | |
release: | |
name: release | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.CR_PAT }} |