Skip to content

Commit f0175d5

Browse files
authored
Merge pull request #401 from fluxcd/sbom-cosign
Publish SBOM and sign release artifacts
2 parents ab9e4f8 + 413d60f commit f0175d5

File tree

6 files changed

+87
-26
lines changed

6 files changed

+87
-26
lines changed

.github/workflows/cifuzz.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
pull_request:
44
branches:
55
- main
6+
7+
permissions:
8+
contents: read # for actions/checkout to fetch code
9+
610
jobs:
711
Fuzzing:
812
runs-on: ubuntu-latest

.github/workflows/e2e.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: e2e
2-
32
on:
43
workflow_dispatch:
54
pull_request:
65
push:
76
branches:
87
- main
98
- "feature/**"
9+
10+
permissions:
11+
contents: read # for actions/checkout to fetch code
12+
1013
jobs:
1114
kind:
1215
runs-on: ubuntu-latest

.github/workflows/nightly.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
- cron: '0 0 * * *'
55
workflow_dispatch:
66

7+
permissions:
8+
contents: read # for actions/checkout to fetch code
9+
710
env:
811
REPOSITORY: ${{ github.repository }}
912

.github/workflows/release.yml

+33-24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
default: 'rc'
1111
required: true
1212

13+
permissions:
14+
contents: write # needed to write releases
15+
id-token: write # needed for keyless signing
16+
packages: write # needed for ghcr access
17+
1318
env:
1419
CONTROLLER: ${{ github.event.repository.name }}
1520

@@ -31,13 +36,9 @@ jobs:
3136
echo ::set-output name=VERSION::${VERSION}
3237
- name: Setup QEMU
3338
uses: docker/setup-qemu-action@v1
34-
with:
35-
platforms: all
3639
- name: Setup Docker Buildx
3740
id: buildx
3841
uses: docker/setup-buildx-action@v1
39-
with:
40-
buildkitd-flags: "--debug"
4142
- name: Login to GitHub Container Registry
4243
uses: docker/login-action@v1
4344
with:
@@ -49,43 +50,51 @@ jobs:
4950
with:
5051
username: fluxcdbot
5152
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
52-
- name: Publish multi-arch container image
53+
- name: Generate images meta
54+
id: meta
55+
uses: docker/metadata-action@v3
56+
with:
57+
images: |
58+
fluxcd/${{ env.CONTROLLER }}
59+
ghcr.io/fluxcd/${{ env.CONTROLLER }}
60+
tags: |
61+
type=raw,value=${{ steps.prep.outputs.VERSION }}
62+
- name: Publish images
5363
uses: docker/build-push-action@v2
5464
with:
5565
push: true
5666
builder: ${{ steps.buildx.outputs.name }}
5767
context: .
5868
file: ./Dockerfile
5969
platforms: linux/amd64,linux/arm/v7,linux/arm64
60-
tags: |
61-
ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
62-
docker.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
63-
labels: |
64-
org.opencontainers.image.title=${{ github.event.repository.name }}
65-
org.opencontainers.image.description=${{ github.event.repository.description }}
66-
org.opencontainers.image.url=${{ github.event.repository.html_url }}
67-
org.opencontainers.image.revision=${{ github.sha }}
68-
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
69-
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
7072
- name: Check images
7173
run: |
7274
docker buildx imagetools inspect docker.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
7375
docker buildx imagetools inspect ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
7476
docker pull docker.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
7577
docker pull ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
76-
- name: Generate release manifests
78+
- uses: sigstore/cosign-installer@main
79+
- name: Sign images
80+
env:
81+
COSIGN_EXPERIMENTAL: 1
82+
run: |
83+
cosign sign fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
84+
cosign sign ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
85+
- name: Generate release artifacts
7786
if: startsWith(github.ref, 'refs/tags/v')
7887
run: |
7988
mkdir -p config/release
8089
kustomize build ./config/crd > ./config/release/${{ env.CONTROLLER }}.crds.yaml
8190
kustomize build ./config/manager > ./config/release/${{ env.CONTROLLER }}.deployment.yaml
82-
- name: Create release
91+
echo '[CHANGELOG](https://github.com/fluxcd/${{ env.CONTROLLER }}/blob/main/CHANGELOG.md)' > ./config/release/notes.md
92+
- uses: anchore/sbom-action/download-syft@v0
93+
- name: Create release and SBOM
8394
if: startsWith(github.ref, 'refs/tags/v')
84-
uses: ncipollo/release-action@v1
95+
uses: goreleaser/goreleaser-action@v2
8596
with:
86-
prerelease: true
87-
artifacts: "config/release/*.yaml"
88-
artifactContentType: "text/plain"
89-
body: |
90-
[CHANGELOG](https://github.com/fluxcd/${{ env.CONTROLLER }}/blob/main/CHANGELOG.md)
91-
token: ${{ secrets.GITHUB_TOKEN }}
97+
version: latest
98+
args: release --release-notes=config/release/notes.md --rm-dist --skip-validate
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/scan.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Scan
2-
32
on:
43
push:
54
branches: [ main ]
@@ -8,6 +7,10 @@ on:
87
schedule:
98
- cron: '18 10 * * 3'
109

10+
permissions:
11+
contents: read # for actions/checkout to fetch code
12+
security-events: write # for codeQL to write security events
13+
1114
jobs:
1215
fossa:
1316
name: FOSSA

.goreleaser.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
project_name: helm-controller
2+
3+
builds:
4+
- skip: true
5+
6+
release:
7+
prerelease: "true"
8+
extra_files:
9+
- glob: config/release/*.yaml
10+
11+
checksum:
12+
extra_files:
13+
- glob: config/release/*.yaml
14+
15+
source:
16+
enabled: true
17+
name_template: "{{ .ProjectName }}_{{ .Version }}_source_code"
18+
19+
sboms:
20+
- id: source
21+
artifacts: source
22+
documents:
23+
- "{{ .ProjectName }}_{{ .Version }}_sbom.spdx.json"
24+
25+
# signs the checksum file
26+
# all files (including the sboms) are included in the checksum
27+
# https://goreleaser.com/customization/sign
28+
signs:
29+
- cmd: cosign
30+
env:
31+
- COSIGN_EXPERIMENTAL=1
32+
certificate: "${artifact}.pem"
33+
args:
34+
- sign-blob
35+
- "--output-certificate=${certificate}"
36+
- "--output-signature=${signature}"
37+
- "${artifact}"
38+
artifacts: checksum
39+
output: true

0 commit comments

Comments
 (0)