Skip to content

Commit f8c6d03

Browse files
authored
Merge pull request #27 from fluxcd/sbom-cosign
Add release workflow (SBOM + Cosign)
2 parents e20134c + 4b97974 commit f8c6d03

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

.github/workflows/release.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write # needed to write releases
10+
id-token: write # needed for keyless signing
11+
packages: write # needed for ghcr access
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.17.x
23+
- uses: actions/cache@v2
24+
with:
25+
path: ~/go/pkg/mod
26+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
27+
restore-keys: |
28+
${{ runner.os }}-go-
29+
- uses: sigstore/cosign-installer@main
30+
- uses: anchore/sbom-action/download-syft@v0
31+
- uses: goreleaser/goreleaser-action@v2
32+
with:
33+
version: latest
34+
args: release --rm-dist
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
project_name: source-watcher
2+
3+
builds:
4+
skip: true
5+
6+
release:
7+
prerelease: auto
8+
9+
changelog:
10+
use: github-native
11+
12+
checksum:
13+
name_template: 'checksums.txt'
14+
15+
source:
16+
enabled: true
17+
18+
sboms:
19+
- artifacts: archive
20+
- id: source
21+
artifacts: source
22+
23+
# signs the checksum file
24+
# all files (including the sboms) are included in the checksum, so we don't need to sign each one if we don't want to
25+
# https://goreleaser.com/customization/sign
26+
signs:
27+
- cmd: cosign
28+
env:
29+
- COSIGN_EXPERIMENTAL=1
30+
certificate: '${artifact}.pem'
31+
args:
32+
- sign-blob
33+
- '--output-certificate=${certificate}'
34+
- '--output-signature=${signature}'
35+
- '${artifact}'
36+
artifacts: checksum
37+
output: true

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ all: manager
1818

1919
# Run tests
2020
KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)"
21-
test: generate fmt vet manifests install-envtest
21+
test: generate tidy fmt vet manifests install-envtest
2222
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test ./... -coverprofile cover.out
2323

2424
# Build manager binary
@@ -46,6 +46,10 @@ deploy: manifests
4646
manifests: controller-gen
4747
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=source-reader webhook paths="./..." output:crd:artifacts:config=config/crd/bases
4848

49+
# Run go tidy to cleanup go.mod
50+
tidy:
51+
go mod tidy
52+
4953
# Run go fmt against code
5054
fmt:
5155
go fmt ./...

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
github.com/fluxcd/pkg/runtime v0.12.3
77
github.com/fluxcd/pkg/untar v0.1.0
88
github.com/fluxcd/source-controller/api v0.20.1
9-
github.com/go-logr/logr v1.2.2
109
github.com/spf13/pflag v1.0.5
1110
k8s.io/apimachinery v0.23.1
1211
k8s.io/client-go v0.23.1
@@ -22,6 +21,7 @@ require (
2221
github.com/fluxcd/pkg/apis/acl v0.0.3 // indirect
2322
github.com/fluxcd/pkg/apis/meta v0.10.2 // indirect
2423
github.com/fsnotify/fsnotify v1.5.1 // indirect
24+
github.com/go-logr/logr v1.2.2 // indirect
2525
github.com/go-logr/zapr v1.2.0 // indirect
2626
github.com/gogo/protobuf v1.3.2 // indirect
2727
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect

0 commit comments

Comments
 (0)