-
Notifications
You must be signed in to change notification settings - Fork 7
180 lines (176 loc) · 6.87 KB
/
release.yml
File metadata and controls
180 lines (176 loc) · 6.87 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
name: Create a new release for RuntimeEnforcer stack
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
strategy:
matrix:
component: [operator, agent]
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
- 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: [operator, agent]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- 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: [operator, agent]
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
- name: Attestation
uses: ./.github/actions/attestation
with:
arch: ${{ matrix.arch }}
image: ${{ matrix.component }}
repo: ${{github.repository}}
artifact_prefix: RuntimeEnforcer-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-release:
needs: [attest]
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.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@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
pattern: attestation-RuntimeEnforcer-*
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R
- name: Upload release assets
id: upload_release_assets
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.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-operator-attestation-amd64-provenance.intoto.jsonl',
'RuntimeEnforcer-operator-attestation-amd64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-operator-attestation-amd64-sbom.json',
'RuntimeEnforcer-operator-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-operator-attestation-arm64-provenance.intoto.jsonl',
'RuntimeEnforcer-operator-attestation-arm64-provenance.intoto.jsonl.bundle.sigstore',
'RuntimeEnforcer-operator-attestation-arm64-sbom.json',
'RuntimeEnforcer-operator-attestation-arm64-sbom.json.bundle.sigstore',
]
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.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
secrets: inherit