1
1
name : release
2
-
3
2
on :
4
3
push :
5
4
tags :
10
9
description : ' image tag prefix'
11
10
default : ' rc'
12
11
required : true
13
-
14
- permissions :
15
- contents : read
16
-
17
- env :
18
- CONTROLLER : ${{ github.event.repository.name }}
19
-
20
12
jobs :
21
13
release :
22
- outputs :
23
- hashes : ${{ steps.hash.outputs.hashes }}
24
- image_url : ${{ steps.hash.outputs.image_url }}
25
- image_digest : ${{ steps.hash.outputs.image_digest }}
26
- runs-on : ubuntu-latest
27
14
permissions :
28
- contents : write # needed to write releases
29
- id-token : write # needed for keyless signing
30
- packages : write # needed for ghcr access
31
- steps :
32
- - name : Checkout
33
- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34
- - name : Setup Kustomize
35
- uses : fluxcd/pkg/actions/kustomize@main
36
- - name : Prepare
37
- id : prep
38
- run : |
39
- VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
40
- if [[ $GITHUB_REF == refs/tags/* ]]; then
41
- VERSION=${GITHUB_REF/refs\/tags\//}
42
- fi
43
- echo "version=${VERSION}" >> $GITHUB_OUTPUT
44
- - name : Setup Go
45
- uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
46
- with :
47
- go-version : 1.25.x
48
- cache-dependency-path : |
49
- **/go.sum
50
- **/go.mod
51
- - uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
52
- - uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
53
- - uses : sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
54
- - uses : anchore/sbom-action/download-syft@da167eac915b4e86f08b264dbdbc867b61be6f0c # v0.20.5
55
- - name : Docker login ghcr.io
56
- uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
57
- with :
58
- registry : ghcr.io
59
- username : fluxcdbot
60
- password : ${{ secrets.GHCR_TOKEN }}
61
- - name : Docker login docker.io
62
- uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
63
- with :
64
- username : fluxcdbot
65
- password : ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
66
- - name : Docker meta
67
- id : meta
68
- uses : docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
69
- with :
70
- images : |
71
- fluxcd/${{ env.CONTROLLER }}
72
- ghcr.io/fluxcd/${{ env.CONTROLLER }}
73
- tags : |
74
- type=raw,value=${{ steps.prep.outputs.version }}
75
- - name : Docker push
76
- uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
77
- id : build-push
78
- with :
79
- sbom : true
80
- provenance : true
81
- push : true
82
- builder : ${{ steps.buildx.outputs.name }}
83
- context : .
84
- file : ./Dockerfile
85
- platforms : linux/amd64,linux/arm/v7,linux/arm64
86
- tags : ${{ steps.meta.outputs.tags }}
87
- labels : ${{ steps.meta.outputs.labels }}
88
- - name : Sign images
89
- env :
90
- COSIGN_EXPERIMENTAL : 1
91
- run : |
92
- cosign sign --yes fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
93
- cosign sign --yes ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
94
- - name : Generate release artifacts
95
- if : startsWith(github.ref, 'refs/tags/v')
96
- run : |
97
- mkdir -p config/release
98
- kustomize build ./config/crd > ./config/release/${{ env.CONTROLLER }}.crds.yaml
99
- kustomize build ./config/manager > ./config/release/${{ env.CONTROLLER }}.deployment.yaml
100
- - name : GoReleaser publish signed SBOM
101
- id : run-goreleaser
102
- if : startsWith(github.ref, 'refs/tags/v')
103
- uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
104
- with :
105
- version : latest
106
- args : release --clean --skip=validate
107
- env :
108
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
109
- - name : Generate SLSA hashes
110
- id : hash
111
- env :
112
- ARTIFACTS : " ${{ steps.run-goreleaser.outputs.artifacts }}"
113
- run : |
114
- set -euo pipefail
115
-
116
- hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
117
- echo "hashes=$hashes" >> $GITHUB_OUTPUT
118
-
119
- image_url=fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
120
- image_digest=${{ steps.build-push.outputs.digest }}
121
- echo "image_url=$image_url" >> $GITHUB_OUTPUT
122
- echo "image_digest=$image_digest" >> $GITHUB_OUTPUT
123
-
15
+ contents : write # for creating the GitHub release.
16
+ id-token : write # for creating OIDC tokens for signing.
17
+ packages : write # for pushing and signing container images.
18
+ uses :
fluxcd/gha-workflows/.github/workflows/[email protected]
19
+ with :
20
+ controller : ${{ github.event.repository.name }}
21
+ release-candidate-prefix : ${{ github.event.inputs.tag }}
22
+ secrets :
23
+ github-token : ${{ secrets.GITHUB_TOKEN }}
24
+ dockerhub-token : ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
124
25
release-provenance :
125
26
needs : [release]
126
27
permissions :
@@ -132,10 +33,10 @@ jobs:
132
33
provenance-name : " provenance.intoto.jsonl"
133
34
base64-subjects : " ${{ needs.release.outputs.hashes }}"
134
35
upload-assets : true
135
-
136
36
dockerhub-provenance :
137
37
needs : [release]
138
38
permissions :
39
+ contents : read # for reading the repository code.
139
40
actions : read # for detecting the Github Actions environment.
140
41
id-token : write # for creating OIDC tokens for signing.
141
42
packages : write # for uploading attestations.
@@ -146,10 +47,10 @@ jobs:
146
47
registry-username : fluxcdbot
147
48
secrets :
148
49
registry-password : ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
149
-
150
50
ghcr-provenance :
151
51
needs : [release]
152
52
permissions :
53
+ contents : read # for reading the repository code.
153
54
actions : read # for detecting the Github Actions environment.
154
55
id-token : write # for creating OIDC tokens for signing.
155
56
packages : write # for uploading attestations.
159
60
digest : ${{ needs.release.outputs.image_digest }}
160
61
registry-username : fluxcdbot
161
62
secrets :
162
- registry-password : ${{ secrets.GHCR_TOKEN }}
63
+ registry-password : ${{ secrets.GHCR_TOKEN }}
0 commit comments