-
Notifications
You must be signed in to change notification settings - Fork 37
164 lines (161 loc) · 6.49 KB
/
go-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
name: GoRelease
on:
push:
tags:
- 'v*'
env:
# Common versions
GO_VERSION: '1.20'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/oamdev/cluster-gateway/go'
GITHUB_REF: ${{ github.ref }}
defaults:
run:
working-directory: go/src/oamdev/cluster-gateway
jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- 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: |
sed -i 's/version: 0.1.0/version: ${{ env.TRIMED_RELEASE_VERSION }}/g' ./charts/cluster-gateway/Chart.yaml
sed -i 's/version: 0.1.0/version: ${{ env.TRIMED_RELEASE_VERSION }}/g' ./charts/addon-manager/Chart.yaml
cat ./charts/cluster-gateway/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}'
cat ./charts/addon-manager/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}'
outputs:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
TRIMED_RELEASE_VERSION: ${{ env.TRIMED_RELEASE_VERSION }}
image-multi-arch:
name: multi arch image build
runs-on: ubuntu-latest
needs: [ env ]
strategy:
matrix:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: images multi arch
run: |
IMG_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \
OS=linux \
ARCH=${{ matrix.arch }} \
make image
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: push image multi arch
run: |
docker push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
docker push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
image-manifest:
name: image-manifest
runs-on: ubuntu-latest
needs: [ env, image-multi-arch ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: create
run: |
docker manifest create oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
docker manifest create oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
- name: annotate
run: |
docker manifest annotate oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64
docker manifest annotate oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64
docker manifest annotate oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64
docker manifest annotate oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64
- name: push
run: |
docker manifest push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}
docker manifest push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}
release:
name: release
runs-on: ubuntu-latest
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: setup helm
uses: azure/setup-helm@v1
- name: chart package
run: |
mkdir -p release
pushd release
helm package ../charts/cluster-gateway/
helm package ../charts/addon-manager/
popd
- name: publish release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.env.outputs.RELEASE_VERSION }}
artifacts: "go/src/oamdev/cluster-gateway/release/*.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
# lack secrets.PAT_TOKEN from ocm, commented now
# - name: submit charts to OCM chart repo
# uses: actions/github-script@v6
# with:
# debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }}
# github-token: ${{ secrets.PAT_TOKEN }}
# 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": "cluster-gateway-addon-manager",
# },
# })
# console.log(result);
# } catch(error) {
# console.error(error);
# core.setFailed(error);
# }