-
Notifications
You must be signed in to change notification settings - Fork 7
236 lines (230 loc) · 9.43 KB
/
release.yml
File metadata and controls
236 lines (230 loc) · 9.43 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Create a new release for RuntimeEnforcer stack
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
strategy:
matrix:
component: [controller, agent, debugger]
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
permissions:
contents: read # Access private repos
packages: write
id-token: write
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Build image
uses: ./.github/actions/container-build
with:
arch: ${{ matrix.arch }}
dockerfile: package/Dockerfile.${{ matrix.component }}
image: ${{ matrix.component }}
repo: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
merge:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read # Access private repos
packages: write # Pushing multi-arch manifest to ghcr.io
id-token: write # Signing images with cosign
strategy:
matrix:
component: [controller, agent, debugger]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Merge images
uses: ./.github/actions/merge-multiarch
with:
arch: amd64,arm64
image: ${{ matrix.component }}
repo: ${{ github.repository }}
tag: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
attest:
name: Sign attestations and upload as artifacts
strategy:
matrix:
component: [controller, agent, debugger]
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-latest
platform: linux/amd64
- arch: arm64
runner: ubuntu-24.04-arm
platform: linux/arm64
needs: [merge]
permissions:
contents: read # Access private repos
packages: write # Uploading signed artifacts to ghcr.io
id-token: write # Signing images with cosign
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Attestation
uses: ./.github/actions/attestation
with:
arch: ${{ matrix.arch }}
image: ${{ matrix.component }}
repo: ${{github.repository}}
artifact_prefix: RuntimeEnforcer-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# kubectl plugin – build binaries for all target platforms via the Makefile.
plugin-build:
name: Plugin build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
cache: false
- name: Build kubectl plugin for all platforms
run: make kubectl-plugin-cross KUBECTL_PLUGIN_VERSION=${GITHUB_REF_NAME}
- name: Generate checksums
run: |
cd bin/kubectl-plugin
for f in kubectl-runtime_enforcer-*; do
sha256sum "$f" > "$f.sha256"
done
- name: Upload plugin artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: kubectl-plugin
path: bin/kubectl-plugin/
if-no-files-found: error
create-release:
needs: [attest, plugin-build]
permissions:
contents: write # Creating a release
runs-on: ubuntu-latest
steps:
- name: Retrieve tag name
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo TAG_NAME=$(echo ${GITHUB_REF_NAME}) >> $GITHUB_ENV
- name: Get release ID from the release created by release drafter
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
let releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
for (const release of releases.data) {
if (release.draft) {
core.info(release)
core.exportVariable('RELEASE_ID', release.id)
return
}
}
core.setFailed(`Draft release not found`)
- name: Download attestation artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: attestation-RuntimeEnforcer-*
merge-multiple: true
- name: Download plugin artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: kubectl-plugin
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R
- name: Upload release assets
id: upload_release_assets
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
let fs = require('fs');
let path = require('path');
let files = [
'RuntimeEnforcer-agent-attestation-amd64-provenance.intoto.jsonl',
'RuntimeEnforcer-agent-attestation-amd64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-agent-attestation-amd64-sbom.json',
'RuntimeEnforcer-agent-attestation-amd64-sbom.json.bundle.sigstore',
'RuntimeEnforcer-controller-attestation-amd64-provenance.intoto.jsonl',
'RuntimeEnforcer-controller-attestation-amd64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-controller-attestation-amd64-sbom.json',
'RuntimeEnforcer-controller-attestation-amd64-sbom.json.bundle.sigstore',
'RuntimeEnforcer-debugger-attestation-amd64-provenance.intoto.jsonl',
'RuntimeEnforcer-debugger-attestation-amd64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-debugger-attestation-amd64-sbom.json',
'RuntimeEnforcer-debugger-attestation-amd64-sbom.json.bundle.sigstore',
'RuntimeEnforcer-agent-attestation-arm64-provenance.intoto.jsonl',
'RuntimeEnforcer-agent-attestation-arm64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-agent-attestation-arm64-sbom.json',
'RuntimeEnforcer-agent-attestation-arm64-sbom.json.bundle.sigstore',
'RuntimeEnforcer-controller-attestation-arm64-provenance.intoto.jsonl',
'RuntimeEnforcer-controller-attestation-arm64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-controller-attestation-arm64-sbom.json',
'RuntimeEnforcer-controller-attestation-arm64-sbom.json.bundle.sigstore',
'RuntimeEnforcer-debugger-attestation-arm64-provenance.intoto.jsonl',
'RuntimeEnforcer-debugger-attestation-arm64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-debugger-attestation-arm64-sbom.json',
'RuntimeEnforcer-debugger-attestation-arm64-sbom.json.bundle.sigstore',
'kubectl-runtime_enforcer-linux-amd64',
'kubectl-runtime_enforcer-linux-amd64.sha256',
'kubectl-runtime_enforcer-linux-arm64',
'kubectl-runtime_enforcer-linux-arm64.sha256',
'kubectl-runtime_enforcer-darwin-amd64',
'kubectl-runtime_enforcer-darwin-amd64.sha256',
'kubectl-runtime_enforcer-darwin-arm64',
'kubectl-runtime_enforcer-darwin-arm64.sha256',
]
const {RELEASE_ID} = process.env
for (const file of files) {
let file_data = fs.readFileSync(file);
let response = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: `${RELEASE_ID}`,
name: path.basename(file),
data: file_data,
});
}
- name: Publish release
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const {RELEASE_ID} = process.env
const {TAG_NAME} = process.env
isPreRelease = ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }}
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: `${RELEASE_ID}`,
draft: false,
tag_name: `${TAG_NAME}`,
name: `RuntimeEnforcer ${TAG_NAME}`,
prerelease: isPreRelease,
make_latest: !isPreRelease
});
update-charts:
needs: [create-release]
uses: ./.github/workflows/update-charts.yml
permissions:
contents: write # for updatecli to update the repository
pull-requests: write # for updatecli to create a PR