Skip to content

Commit 2cbd51b

Browse files
committed
chore(ci): add fork-friendly release workflow for testing
1 parent be5dca0 commit 2cbd51b

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

.github/workflows/release-fork.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release (fork test)
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
7+
jobs:
8+
release:
9+
name: Release (RPM/DEB only)
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Go
20+
uses: ./.github/actions/setup-go
21+
22+
- name: Save GPG key to file
23+
env:
24+
GPG_KEY: ${{ secrets.GPG_KEY }}
25+
run: echo "$GPG_KEY" > /tmp/gpg.key
26+
27+
- name: GoReleaser (RPM/DEB only)
28+
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.3.0
29+
with:
30+
version: ~> v2
31+
args: release -f goreleaser-fork.yml --clean --timeout 30m
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
NFPM_DEFAULT_RPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
35+
GPG_FILE: /tmp/gpg.key
36+
37+
- name: Remove GPG key file
38+
if: always()
39+
run: rm -f /tmp/gpg.key
40+
41+
deploy-packages:
42+
name: Trigger deploy-packages
43+
needs: release
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Trigger deploy-packages workflow in trivy-repo
47+
env:
48+
GH_TOKEN: ${{ secrets.ORG_REPO_TOKEN }}
49+
run: |
50+
gh workflow run deploy-packages.yml \
51+
--repo "$GITHUB_REPOSITORY_OWNER/trivy-repo" \
52+
--ref main \
53+
--field "version=$GITHUB_REF_NAME"

goreleaser-fork.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: 2
2+
3+
project_name: trivy
4+
5+
builds:
6+
- id: build-linux
7+
main: ./cmd/trivy/
8+
binary: trivy
9+
ldflags:
10+
- -s -w
11+
- "-extldflags '-static'"
12+
- -X github.com/aquasecurity/trivy/pkg/version/app.ver={{.Version}}
13+
env:
14+
- CGO_ENABLED=0
15+
- GOEXPERIMENT=jsonv2
16+
goos:
17+
- linux
18+
goarch:
19+
- amd64
20+
- arm64
21+
22+
release:
23+
discussion_category_name: ""
24+
25+
nfpms:
26+
-
27+
formats:
28+
- deb
29+
- rpm
30+
vendor: "aquasecurity"
31+
homepage: "https://github.com/aquasecurity"
32+
maintainer: "Aqua Security <oss@aquasec.com>"
33+
description: "A Fast Vulnerability Scanner for Containers"
34+
license: "Apache-2.0"
35+
file_name_template: >-
36+
{{ .ProjectName }}_{{ .Version }}_
37+
{{- if eq .Os "darwin" }}macOS
38+
{{- else if eq .Os "openbsd" }}OpenBSD
39+
{{- else if eq .Os "netbsd" }}NetBSD
40+
{{- else if eq .Os "freebsd" }}FreeBSD
41+
{{- else if eq .Os "dragonfly" }}DragonFlyBSD
42+
{{- else}}{{- title .Os }}{{ end }}-
43+
{{- if eq .Arch "amd64" }}64bit
44+
{{- else if eq .Arch "386" }}32bit
45+
{{- else if eq .Arch "arm" }}ARM
46+
{{- else if eq .Arch "arm64" }}ARM64
47+
{{- else if eq .Arch "ppc64le" }}PPC64LE
48+
{{- else }}{{ .Arch }}{{ end }}
49+
contents:
50+
- src: contrib/*.tpl
51+
dst: /usr/local/share/trivy/templates
52+
rpm:
53+
signature:
54+
key_file: '{{ .Env.GPG_FILE }}'

0 commit comments

Comments
 (0)