-
Notifications
You must be signed in to change notification settings - Fork 8
129 lines (110 loc) · 3.72 KB
/
Copy pathrelease.yaml
File metadata and controls
129 lines (110 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
id-token: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Install Syft
uses: anchore/sbom-action/download-syft@v0
- name: Generate install manifest
run: make installer
- name: Run GoReleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sign container image tags with cosign (keyless OIDC)
env:
COSIGN_EXPERIMENTAL: "true"
run: |
IMAGE="ghcr.io/stubbi/hermes-operator"
TAG="${{ github.ref_name }}"
MAJOR_MINOR=$(echo "$TAG" | sed 's/^v//' | cut -d. -f1,2)
for t in "${TAG}" "${MAJOR_MINOR}" "latest"; do
DIGEST=$(docker buildx imagetools inspect "${IMAGE}:${t}" --format '{{.Manifest.Digest}}' 2>/dev/null || true)
if [ -n "$DIGEST" ]; then
cosign sign --yes "${IMAGE}@${DIGEST}"
fi
done
- name: Generate SBOM for container image
uses: anchore/sbom-action@v0
with:
image: ghcr.io/stubbi/hermes-operator:${{ github.ref_name }}
artifact-name: sbom-${{ github.ref_name }}.spdx.json
output-file: sbom-${{ github.ref_name }}.spdx.json
- name: Attest SBOM with cosign
env:
COSIGN_EXPERIMENTAL: "true"
run: |
IMAGE="ghcr.io/stubbi/hermes-operator"
TAG="${{ github.ref_name }}"
DIGEST=$(docker buildx imagetools inspect "${IMAGE}:${TAG}" --format '{{.Manifest.Digest}}' 2>/dev/null || true)
if [ -n "$DIGEST" ]; then
cosign attest --yes --predicate "sbom-${TAG}.spdx.json" --type spdxjson "${IMAGE}@${DIGEST}"
fi
- name: Upload SBOM to GitHub release
uses: softprops/action-gh-release@v2
with:
files: sbom-${{ github.ref_name }}.spdx.json
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
- name: Publish release (undraft)
uses: softprops/action-gh-release@v2
with:
draft: false
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
helm-release:
name: Helm OCI Release
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Helm
uses: azure/setup-helm@v5
with:
version: latest
- name: Package and push Helm chart
run: |
CHART_VERSION="${{ github.ref_name }}"
CHART_VERSION="${CHART_VERSION#v}"
helm package charts/hermes-operator \
--version "${CHART_VERSION}" \
--app-version "${{ github.ref_name }}"
helm push hermes-operator-${CHART_VERSION}.tgz oci://ghcr.io/stubbi/charts