-
Notifications
You must be signed in to change notification settings - Fork 23
204 lines (199 loc) · 8.44 KB
/
go-release.yaml
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
name: GoRelease
on:
push:
tags:
- 'v*.*.*'
env:
# Common versions
GO_VERSION: '1.22'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicluster-controlplane/multicluster-controlplane/go'
GITHUB_REF: ${{ github.ref }}
CHART_NAME: 'multicluster-controlplane'
defaults:
run:
working-directory: go/src/open-cluster-management.io/multicluster-controlplane
jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/multicluster-controlplane
- name: get release version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: get major release version
run: |
echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV
echo "TRIMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV
- name: verify chart version
run: |
cat ./charts/multicluster-controlplane/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}'
outputs:
MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
TRIMED_RELEASE_VERSION: ${{ env.TRIMED_RELEASE_VERSION }}
image:
name: image
runs-on: ubuntu-latest
needs: [ env ]
strategy:
matrix:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/multicluster-controlplane
- name: install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: install imagebuilder
run: go install github.com/openshift/imagebuilder/cmd/[email protected]
- name: pull base image
run: docker pull registry.access.redhat.com/ubi8/ubi-minimal:latest --platform=linux/${{ matrix.arch }}
- name: image
run: |
IMAGE_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \
IMAGE_BUILD_EXTRA_FLAGS="--build-arg OS=linux --build-arg ARCH=${{ matrix.arch }}" \
make image
- name: push
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
docker push quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
image-manifest:
name: image manifest
runs-on: ubuntu-latest
needs: [ env, image ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/multicluster-controlplane
- name: create
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
docker manifest create quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }} \
quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
- name: annotate
run: |
docker manifest annotate quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }} \
quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64
docker manifest annotate quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }} \
quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64
- name: push
run: |
docker manifest push quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}
release-image:
name: Release Image
runs-on: ubuntu-latest
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/multicluster-controlplane
- name: generate changelog
run: |
echo "# Controlplane ${{ needs.env.outputs.RELEASE_VERSION }}" > /home/runner/work/changelog.txt
echo "- See the [CHANGELOG](https://github.com/open-cluster-management-io/multicluster-controlplane/CHANGELOG/CHANGELOG-${{ needs.env.outputs.MAJOR_RELEASE_VERSION }}.md) for more details." >> /home/runner/work/changelog.txt
echo "- The released image is quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}" >> /home/runner/work/changelog.txt
- name: publish release
uses: softprops/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: /home/runner/work/changelog.txt
release-chart:
name: Release Chart
runs-on: ubuntu-latest
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/multicluster-controlplane
- name: setup helm
uses: azure/setup-helm@v1
- name: chart package
run: |
mkdir -p release
pushd release
helm package ../charts/${{ env.CHART_NAME }}/
popd
- name: publish release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_VERSION }}
artifacts: "go/src/open-cluster-management.io/multicluster-controlplane/release/*.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
- name: submit charts to OCM chart repo
uses: actions/github-script@v6
with:
github-token: ${{ secrets.OCM_BOT_PAT }}
script: |
try {
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'open-cluster-management-io',
repo: 'helm-charts',
workflow_id: 'download-chart.yml',
ref: 'main',
inputs: {
repo: "${{ github.repository }}",
version: "${{ needs.env.outputs.TRIMED_RELEASE_VERSION }}",
"chart-name": "${{ env.CHART_NAME }}",
},
})
console.log(result);
} catch(error) {
console.error(error);
core.setFailed(error);
}
release-binary:
name: Release Binary
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/multicluster-controlplane
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: generate changelog
run: |
echo "# Controlplane ${{ needs.env.outputs.RELEASE_VERSION }}" > /home/runner/work/changelog.txt
echo "- See the [CHANGELOG](https://github.com/open-cluster-management-io/multicluster-controlplane/blob/main/CHANGELOG/CHANGELOG-${{ needs.env.outputs.MAJOR_RELEASE_VERSION }}.md) for more details." >> /home/runner/work/changelog.txt
echo "- The released image is quay.io/open-cluster-management/multicluster-controlplane:${{ needs.env.outputs.RELEASE_VERSION }}" >> /home/runner/work/changelog.txt
- name: Build binaries
run: |
make vendor && make build-bin-release
- name: Release
uses: softprops/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: /home/runner/work/changelog.txt
files: |
bin/multicluster_controlplane_darwin_amd64.tar.gz
bin/multicluster_controlplane_darwin_arm64.tar.gz
bin/multicluster_controlplane_linux_amd64.tar.gz
bin/multicluster_controlplane_linux_arm64.tar.gz
bin/multicluster_controlplane_linux_ppc64le.tar.gz
bin/multicluster_controlplane_linux_s390x.tar.gz
bin/multicluster_controlplane_windows_amd64.zip
draft: false
prerelease: false