22# Replaces pr.yaml and the tag-driven parts of release-please.
33#
44# On tag (v*): release workflow has already bumped Chart/values/package.json and pushed
5- # the tag. This workflow builds gitops-server image ( :X.Y.Z and :latest), pushes the
6- # Helm chart OCI, and runs goreleaser for gitops CLI binaries.
5+ # the tag. This workflow:
6+ # - build-push-gitops-server: builds and pushes gitops-server image (:tag, :latest)
7+ # with provenance (mode=max) and SBOM attestations; keyless cosign signing and verify
8+ # - build-and-push-chart: packages Helm chart, pushes OCI, keyless cosign sign and verify
9+ # - goreleaser: builds gitops CLI binaries (linux/darwin, amd64/arm64), signs with cosign,
10+ # uploads to GitHub Release (mode: keep-existing). For non-prerelease tags, includes
11+ # Homebrew tap publish (.goreleaser.brew.yml).
712#
813# Runs on main and feature/re-implement-workflows (for testing). Fork-friendly: image,
914# chart and goreleaser use github.repository / github.repository_owner (your fork when
8994 permissions :
9095 contents : read
9196 packages : write
97+ id-token : write
9298 steps :
9399 - uses : actions/checkout@v4
94100 with :
@@ -112,6 +118,7 @@ jobs:
112118 password : ${{ secrets.GITHUB_TOKEN }}
113119
114120 - name : Build and push gitops-server
121+ id : build
115122 uses : docker/build-push-action@v5
116123 with :
117124 context : .
@@ -120,13 +127,28 @@ jobs:
120127 LDFLAGS=${{ env.LDFLAGS }}
121128 GIT_COMMIT=${{ github.sha }}
122129 push : true
130+ provenance : " mode=max"
131+ sbom : true
123132 tags : |
124133 ghcr.io/${{ github.repository }}/gitops-server:${{ github.ref_name }}
125134 ghcr.io/${{ github.repository }}/gitops-server:latest
126135 cache-from : type=gha
127136 cache-to : type=gha,mode=max
128137 platforms : linux/amd64,linux/arm64
129138
139+ - name : Install cosign
140+ uses : sigstore/cosign-installer@v4
141+
142+ - name : Keyless signing of image
143+ run : |
144+ cosign sign --yes ghcr.io/${{ github.repository }}/gitops-server@${{ steps.build.outputs.digest }}
145+
146+ - name : Verify the image signing
147+ run : |
148+ cosign verify ghcr.io/${{ github.repository }}/gitops-server@${{ steps.build.outputs.digest }} \
149+ --certificate-identity "https://github.com/${{ github.workflow_ref }}" \
150+ --certificate-oidc-issuer "https://token.actions.githubusercontent.com" | jq .
151+
130152 build-and-push-chart :
131153 name : Build and push Helm chart
132154 needs : [build-and-test]
@@ -135,6 +157,7 @@ jobs:
135157 permissions :
136158 contents : read
137159 packages : write
160+ id-token : write
138161 steps :
139162 - uses : actions/checkout@v4
140163 with :
@@ -149,10 +172,27 @@ jobs:
149172 echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
150173
151174 - name : Package and push chart
175+ id : push-chart
152176 run : |
153177 helm package charts/gitops-server -d /tmp
154178 CHART=$(ls /tmp/weave-gitops-*.tgz)
155- helm push "$CHART" oci://ghcr.io/${{ github.repository_owner }}
179+ helm push "$CHART" oci://ghcr.io/${{ github.repository_owner }} 2>&1 | tee /tmp/push.log
180+ CHART_DIGEST=$(awk '/Digest: /{print $2}' /tmp/push.log)
181+ [ -n "$CHART_DIGEST" ] || { echo "Could not parse digest from helm push"; cat /tmp/push.log; exit 1; }
182+ echo "digest=$CHART_DIGEST" >> $GITHUB_OUTPUT
183+
184+ - name : Install cosign
185+ uses : sigstore/cosign-installer@v4
186+
187+ - name : Keyless signing of chart
188+ run : |
189+ cosign sign --yes ghcr.io/${{ github.repository_owner }}/weave-gitops@${{ steps.push-chart.outputs.digest }}
190+
191+ - name : Verify the chart signing
192+ run : |
193+ cosign verify ghcr.io/${{ github.repository_owner }}/weave-gitops@${{ steps.push-chart.outputs.digest }} \
194+ --certificate-identity "https://github.com/${{ github.workflow_ref }}" \
195+ --certificate-oidc-issuer "https://token.actions.githubusercontent.com" | jq .
156196
157197 goreleaser :
158198 name : Goreleaser (gitops CLI)
@@ -161,6 +201,7 @@ jobs:
161201 runs-on : ubuntu-latest
162202 permissions :
163203 contents : write
204+ id-token : write
164205 env :
165206 FLUX_VERSION : " 2.7.2"
166207 steps :
@@ -178,6 +219,13 @@ jobs:
178219 - name : Set CHART_VERSION from tag
179220 run : echo "CHART_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
180221
222+ - name : Include brew publishing
223+ if : " !contains(github.ref_name, '-')"
224+ run : cat .goreleaser.brew.yml >> .goreleaser.yml
225+
226+ - name : Install cosign
227+ uses : sigstore/cosign-installer@v4
228+
181229 - uses : goreleaser/goreleaser-action@v6
182230 with :
183231 distribution : goreleaser
0 commit comments