mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
129 lines
4.3 KiB
YAML
129 lines
4.3 KiB
YAML
name: Reusable release
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
goreleaser_config:
|
|
description: 'file path to GoReleaser config'
|
|
required: true
|
|
type: string
|
|
goreleaser_options:
|
|
description: 'GoReleaser options separated by spaces'
|
|
default: ''
|
|
required: false
|
|
type: string
|
|
|
|
env:
|
|
GH_USER: "aqua-bot"
|
|
|
|
jobs:
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest-m
|
|
env:
|
|
DOCKER_CLI_EXPERIMENTAL: "enabled"
|
|
permissions:
|
|
id-token: write # For cosign
|
|
packages: write # For GHCR
|
|
contents: read # Not required for public repositories, but for clarity
|
|
steps:
|
|
- name: Cosign install
|
|
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
|
|
|
- name: Show available Docker Buildx platforms
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
|
|
- name: Login to docker.io registry
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USER }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to ghcr.io registry
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ env.GH_USER }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to ECR
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
registry: public.ecr.aws
|
|
username: ${{ secrets.ECR_ACCESS_KEY_ID }}
|
|
password: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: false # Disable cache to avoid free space issues during `Post Setup Go` step.
|
|
|
|
- name: Generate SBOM
|
|
uses: CycloneDX/gh-gomod-generate-sbom@efc74245d6802c8cefd925620515442756c70d8f # v2.0.0
|
|
with:
|
|
args: mod -licenses -json -output bom.json
|
|
version: ^v1
|
|
|
|
- name: "save gpg key"
|
|
env:
|
|
GPG_KEY: ${{ secrets.GPG_KEY }}
|
|
run: |
|
|
echo "$GPG_KEY" > gpg.key
|
|
|
|
# Create tmp dir for GoReleaser
|
|
- name: "create tmp dir"
|
|
run: |
|
|
mkdir tmp
|
|
|
|
- name: GoReleaser
|
|
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
|
|
with:
|
|
version: v2.1.0
|
|
args: release -f=${{ inputs.goreleaser_config}} ${{ inputs.goreleaser_options}}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.ORG_REPO_TOKEN }}
|
|
NFPM_DEFAULT_RPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
|
GPG_FILE: "gpg.key"
|
|
TMPDIR: "tmp"
|
|
|
|
- name: "remove gpg key"
|
|
run: |
|
|
rm gpg.key
|
|
|
|
# Push images to registries (only for canary build)
|
|
# The custom Dockerfile.canary is necessary
|
|
# because GoReleaser Free doesn't support pushing images with the `--snapshot` flag.
|
|
- name: Build and push
|
|
if: ${{ inputs.goreleaser_config == 'goreleaser-canary.yml' }}
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
platforms: linux/amd64, linux/arm64
|
|
file: ./Dockerfile.canary # path to Dockerfile
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
aquasec/trivy:canary
|
|
ghcr.io/aquasecurity/trivy:canary
|
|
public.ecr.aws/aquasecurity/trivy:canary
|
|
|
|
- name: Cache Trivy binaries
|
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
|
|
with:
|
|
path: dist/
|
|
# use 'github.sha' to create a unique cache folder for each run.
|
|
# use 'github.workflow' to create a unique cache folder if some runs have same commit sha.
|
|
# e.g. build and release runs
|
|
key: ${{ runner.os }}-bins-${{github.workflow}}-${{github.sha}}
|