-
Notifications
You must be signed in to change notification settings - Fork 15
187 lines (165 loc) · 6.78 KB
/
release-operator.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
# Copyright 2022 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release operator
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-?*'
jobs:
build:
name: Build image and bundle
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/streamnative
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
IMAGE_TAG_BASE: docker.cloudsmith.io/streamnative/operators/pulsar-resources-operator
IMAGE_TAG_BASE_QUAY: docker.cloudsmith.io/streamnative/operators/pulsar-resources-operator
IMAGE_TAG_BASE_DOCKERHUB: docker.io/streamnative/pulsar-resources-operator
REDHAT_API_KEY: ${{ secrets.REDHAT_API_KEY }}
outputs:
version: ${{ steps.redhat.outputs.version }}
channels: ${{ steps.redhat.outputs.channels }}
default_channel: ${{ steps.redhat.outputs.default_channel }}
steps:
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: '1.21'
id: go
- name: Set up Git token
run: |
git config --global url."https://${ACCESS_TOKEN}:@github.com/".insteadOf "https://github.com/"
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Setup operator-sdk
run: |
wget https://github.com/operator-framework/operator-sdk/releases/download/v1.31.0/operator-sdk_linux_amd64 -O operator-sdk
chmod +x operator-sdk
mv operator-sdk /usr/local/bin/
operator-sdk version
- name: Login to CloudSmith
uses: docker/login-action@v2
with:
registry: docker.cloudsmith.io
username: ${{ secrets.CLOUDSMITH_USERNAME }}
password: ${{ secrets.CLOUDSMITH_PASSWORD }}
- name: Login to Quay
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_DOCKER_USERNAME }}
password: ${{ secrets.QUAY_DOCKER_PASSWORD }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
# CloudSmith: To be removed after we fully migrate to DockerHub
- name: Build image and Publish to CloudSmith
run: |
_tag_version=${GITHUB_REF##*/}
export VERSION=${_tag_version/v/}
echo $_tag_version, $VERSION
export IMG=$IMAGE_TAG_BASE:v$VERSION
make docker-build
make docker-push
- name: Build image and Publish to DockerHub
id: dockerhub
run: |
_tag_version=${GITHUB_REF##*/}
export VERSION=${_tag_version/v/}
echo $_tag_version, $VERSION
export IMG=$IMAGE_TAG_BASE_DOCKERHUB:v$VERSION
echo "resource-operator-image=$IMG" >> $GITHUB_OUTPUT
make docker-build
make docker-push
- name: Build image And Publish to Quay
id: redhat
run: |
_tag_version=${GITHUB_REF##*/}
export VERSION=${_tag_version/v/}
echo $_tag_version, $VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
export IMG=$IMAGE_TAG_BASE_QUAY:v$VERSION
export IMG_LATEST=$IMAGE_TAG_BASE_QUAY:latest
make docker-build-redhat
wget https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/download/1.9.6/preflight-linux-amd64 -O preflight
chmod +x preflight
mv preflight /usr/local/bin
preflight -v
make docker-push-redhat
make redhat-preflight-check-image
make report-preflight-check-result
export BUNDLE_IMG=$IMAGE_TAG_BASE_QUAY-bundle:v$VERSION
export CHANNELS=alpha,beta,stable
export DEFAULT_CHANNEL=alpha
echo "channels=$CHANNELS" >> $GITHUB_OUTPUT
echo "default_channel=$DEFAULT_CHANNEL" >> $GITHUB_OUTPUT
make bundle-redhat
make bundle-build
make bundle-push
operatorhub:
name: Create PR to the operatorhub
needs: build
runs-on: ubuntu-latest
steps:
- name: Sync up the upstream
env:
GITHUB_TOKEN: ${{ secrets.SNBOT_GITHUB_TOKEN }}
run: |
gh repo sync streamnative/community-operators
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Checkout streamnative community-operators
uses: actions/checkout@v3
with:
repository: streamnative/community-operators
path: community-operators
token: ${{ secrets.SNBOT_GITHUB_TOKEN }}
- name: Setup operator-sdk
run: |
wget https://github.com/operator-framework/operator-sdk/releases/download/v1.31.0/operator-sdk_linux_amd64 -O operator-sdk
chmod +x operator-sdk
mv operator-sdk /usr/local/bin/
operator-sdk version
- name: Genarate bundle
env:
VERSION: ${{ needs.build.outputs.version }}
CHANNELS: ${{ needs.build.outputs.channels }}
DEFAULT_CHANNEL: ${{ needs.build.outputs.default_channel }}
IMAGE_TAG_BASE_RELEASE: olm.streamnative.io/streamnativeio/pulsar-resources-operator
run: |
export IMG=$IMAGE_TAG_BASE_RELEASE:v$VERSION
make bundle-redhat
- name: Copy bundle to community-operators and create pr
env:
GITHUB_TOKEN: ${{ secrets.SNBOT_GITHUB_TOKEN }}
VERSION: ${{ needs.build.outputs.version }}
OPERATOR_NAME: pulsar-resources-operator
run: |
pushd community-operators
git config --global user.email "[email protected]"
git config --global user.name "streamnativebot"
git push -d origin $OPERATOR_NAME-$VERSION || echo 'Skip branch deletion'
git checkout -b $OPERATOR_NAME-$VERSION
export TARGET_DIR=operators/$OPERATOR_NAME/$VERSION
mkdir -p $TARGET_DIR
cp -rf ../bundle.Dockerfile $TARGET_DIR
cp -rf ../bundle/* $TARGET_DIR
git add .
git commit -s -m "operator $OPERATOR_NAME ($VERSION)"
git push --set-upstream origin $OPERATOR_NAME-$VERSION
gh pr create --title "operator $OPERATOR_NAME ($VERSION)" -F ../.github/operatorhub/community-operators -R k8s-operatorhub/community-operators
popd