-
Notifications
You must be signed in to change notification settings - Fork 929
227 lines (226 loc) · 8.51 KB
/
release.yml
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
on:
release:
types:
- published
name: Build Release
permissions:
contents: read
jobs:
release-assests:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: release kubectl-karmada
runs-on: ubuntu-22.04
strategy:
matrix:
target:
- karmadactl
- kubectl-karmada
os:
- linux
- darwin
arch:
- amd64
- arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Making and packaging
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: make release-${{ matrix.target }}
- name: upload cli
uses: actions/upload-artifact@v4
with:
name: cli-${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
path: _output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
- name: Uploading assets...
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v2
with:
files: |
_output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
_output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz.sha256
generate-subject-for-cli-provenance:
needs: [release-assests]
runs-on: ubuntu-22.04
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
steps:
- name: download cli
uses: actions/download-artifact@v4
with:
path: _output/release
pattern: cli-*
merge-multiple: true
- name: generate cli hash
id: hash
run: |
cd _output/release
# sha256sum generates sha256 hash for cli.
# base64 -w0 encodes to base64 and outputs on a single line.
echo "hashes=$(sha256sum *.tgz|base64 -w0)" >> "$GITHUB_OUTPUT"
cli-provenance:
needs: [generate-subject-for-cli-provenance]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.generate-subject-for-cli-provenance.outputs.hashes }}"
provenance-name: "karmada-cli.intoto.jsonl"
upload-assets: true
release-crds-assests:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: release crds
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Rename the crds directory
run: |
mv ./charts/karmada/_crds ./charts/karmada/crds
- name: Tar the crds
uses: a7ul/[email protected]
with:
command: c
cwd: ./charts/karmada/
files: crds
outPath: crds.tar.gz
- name: generate crds hash
id: hash
run: |
# sha256sum generates sha256 hash for crds.
# base64 -w0 encodes to base64 and outputs on a single line.
echo "hashes=$(sha256sum crds.tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Uploading crd assets...
uses: softprops/action-gh-release@v2
with:
files: |
crds.tar.gz
crds-provenance:
needs: [release-crds-assests]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.release-crds-assests.outputs.hashes }}"
provenance-name: "karmada-crds.intoto.jsonl"
upload-assets: true
release-charts:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: Release charts
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Making helm charts
env:
VERSION: ${{ github.ref_name }}
run: make package-chart
- name: Uploading assets...
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v2
with:
files: |
_output/charts/karmada-chart-${{ github.ref_name }}.tgz
_output/charts/karmada-chart-${{ github.ref_name }}.tgz.sha256
_output/charts/karmada-operator-chart-${{ github.ref_name }}.tgz
_output/charts/karmada-operator-chart-${{ github.ref_name }}.tgz.sha256
- name: generate charts hash
id: hash
run: |
cd _output/charts
echo "hashes=$(sha256sum *.tgz|base64 -w0)" >> "$GITHUB_OUTPUT"
charts-provenance:
needs: [release-charts]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.release-charts.outputs.hashes }}"
provenance-name: "karmada-charts.intoto.jsonl"
upload-assets: true
sbom-assests:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: Release sbom
outputs:
hashes: ${{ steps.sbom-hash.outputs.hashes}}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Generate sbom for karmada file system
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
format: 'spdx'
output: 'sbom-karmada.spdx'
scan-ref: "${{ github.workspace }}/"
- name: Tar the sbom files
run: |
tar -zcf sbom.tar.gz *.spdx
- name: Generate SBOM hash
shell: bash
id: sbom-hash
run: |
# sha256sum generates sha256 hash for sbom.
# base64 -w0 encodes to base64 and outputs on a single line.
echo "hashes=$(sha256sum sbom.tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Uploading sbom assets...
uses: softprops/action-gh-release@v2
with:
files: |
sbom.tar.gz
sbom-provenance:
needs: [sbom-assests]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.sbom-assests.outputs.hashes }}"
provenance-name: "karmada-sbom.intoto.jsonl"
upload-assets: true
update-krew-index:
env:
GH_TOKEN: ${{ github.token }}
needs:
- release-assests
# prevent job running from forked repository, otherwise
# 1. running on the forked repository would use unnecessary GitHub Action time.
# 2. running on the forked repository would open a PR to publish an inaccurate version of karmada in repo kubernetes-sigs/krew-index.
if: ${{ github.repository == 'karmada-io/karmada' }}
name: Update krew-index
runs-on: ubuntu-22.04
steps:
- name: get latest tag
id: get-latest-tag
run: |
export LATEST_TAG=`gh api repos/karmada-io/karmada/releases/latest | jq -r '.tag_name'`
echo "Got the latest tag:$LATEST_TAG"
echo "event.tag:"${{ github.event.release.tag_name }}
echo "latestTag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
if: steps.get-latest-tag.outputs.latestTag == github.event.release.tag_name
- name: Update new version in krew-index
if: steps.get-latest-tag.outputs.latestTag == github.event.release.tag_name
uses: rajatjindal/[email protected]