Files
probo/.github/workflows/release.yaml
2025-07-14 17:20:03 +02:00

131 lines
3.6 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
id-token: write
attestations: write
jobs:
release:
runs-on: ubuntu-latest
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
image-digest: ${{ steps.image.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Install Syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- name: Install Grype
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
- name: Install Cosign
uses: sigstore/cosign-installer@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate SBOM for attestation
run: |
syft dir:. --output cyclonedx-json --source-name probod --source-version ${{ github.ref_name }} > sbom.json
- name: Scan SBOM for vulnerabilities
run: |
echo "Scanning SBOM for vulnerabilities..."
grype sbom:sbom.json --fail-on critical --output table
echo "Vulnerability scan completed successfully - no critical vulnerabilities found"
- name: Generate subject for attestation
id: hash
run: |
set -euo pipefail
(
cd dist
find . -type f -name '*.tar.gz' -o -name '*.zip' | while read file; do
echo "$(sha256sum "$file" | head -c 64) $file"
done
) > checksums.txt
echo "hashes=$(cat checksums.txt | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Attest SBOM
uses: actions/attest-sbom@v1
with:
subject-path: "dist/*.tar.gz, dist/*.zip"
sbom-path: "sbom.json"
- name: Attest build provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: "dist/*.tar.gz, dist/*.zip"
- name: Get image digest
id: image
run: |
echo "Getting image digest..."
DIGEST=$(docker buildx imagetools inspect ghcr.io/getprobo/probo:${{ github.ref_name }} --format '{{json .Manifest.Digest}}' | jq -r)
echo "Successfully retrieved digest: $DIGEST"
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
- name: Attest Docker image SBOM
uses: actions/attest-sbom@v1
with:
subject-name: "ghcr.io/getprobo/probo"
subject-digest: ${{ steps.image.outputs.digest }}
sbom-path: "sbom.json"
- name: Upload SBOM as artifact
uses: actions/upload-artifact@v4
with:
name: sbom
path: |
sbom.json
checksums.txt
retention-days: 30