-
Notifications
You must be signed in to change notification settings - Fork 0
343 lines (299 loc) · 11.9 KB
/
publish-mc-packages.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Publish Hazelcast Management Center packages
on:
push:
# Push to master updates the latest snapshot (MC_VERSION taken from pom.xml)
branches:
- master
# Push of a matching tag (v*, e.g. v5.0.2) starts build with
# - MC_VERSION extracted from pom.xml
# - PACKAGE_VERSION extracted from the tag
tags:
- 'v*'
pull_request:
types: [ opened, synchronize, edited ]
workflow_dispatch:
inputs:
MC_VERSION:
type: string
description: 'Version of Hazelcast Management Center to build the image for, this is the Maven version - e.g.: 5.0.2 or 5.1-SNAPSHOT'
required: true
package_types:
description: 'Packages to build'
required: true
default: 'all'
type: choice
options:
- all
- deb
- rpm
- homebrew
env:
EVENT_NAME: ${{ github.event_name }}
PUBLISH: "true"
ARTIFACTORY_SECRET: ${{ secrets.ARTIFACTORY_SECRET }}
DEVOPS_PRIVATE_KEY: ${{ secrets.DEVOPS_PRIVATE_KEY }}
BINTRAY_PASSPHRASE: ${{ secrets.BINTRAY_PASSPHRASE }}
HZ_LICENSEKEY: ${{ secrets.HZ_LICENSEKEY }}
# Constant for now - should ensure single build, maybe we can limit this to something from github.*
concurrency: single-build
jobs:
prepare:
runs-on: ubuntu-latest
env:
MC_VERSION: ${{ inputs.MC_VERSION }}
defaults:
run:
working-directory: ./management-center-packaging
outputs:
mc_version: ${{ steps.mc_version.outputs.mc_version }}
package_version: ${{ steps.package_version.outputs.package_version }}
package_types: ${{ inputs.package_types || 'all' }}
steps:
- name: Checkout management-center-packaging repo
uses: actions/checkout@v3
with:
path: 'management-center-packaging'
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'temurin'
- name: Set MC_VERSION
id: mc_version
run: |
if [ -z "${{ env.MC_VERSION }}" ]; then
MC_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
fi
echo "MC_VERSION=$MC_VERSION" >> $GITHUB_ENV
echo ::set-output name=mc_version::$MC_VERSION
- name: Set PACKAGE_VERSION
id: package_version
# If the ref is version (e.g. v5.0.1) tag then use it as package version,
# otherwise use MC_VERSION for package version (e.g 5.1-SNAPSHOT)
run: |
if [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
PACKAGE_VERSION=$(echo ${{ github.ref }} | cut -c 12-)
else
PACKAGE_VERSION=${{ env.MC_VERSION }}
fi
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo ::set-output name=package_version::$PACKAGE_VERSION
deb:
runs-on: ubuntu-latest
if: ${{ needs.prepare.outputs.package_types == 'all' || needs.prepare.outputs.package_types == 'deb' }}
env:
MC_VERSION: ${{ needs.prepare.outputs.mc_version }}
PACKAGE_VERSION: ${{ needs.prepare.outputs.package_version }}
defaults:
run:
working-directory: ./management-center-packaging
needs: [prepare]
steps:
- name: Checkout management-center-packaging repo
uses: actions/[email protected]
with:
path: 'management-center-packaging'
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'temurin'
- name: Download the distribution tar.gz file
run: |
if [[ "${MC_VERSION}" != *SNAPSHOT* ]]; then
VERSION="${MC_VERSION}"
else
VERSION=latest-snapshot
fi
MC_PACKAGE_URL="https://repository.hazelcast.com/download/management-center/hazelcast-management-center-${VERSION}.tar.gz"
echo "MC_PACKAGE_URL=$MC_PACKAGE_URL" >> $GITHUB_ENV
curl --silent --fail --location "${MC_PACKAGE_URL}" --output hazelcast-management-center-${MC_VERSION}.tar.gz
- name: Create & Upload DEB package
run: |
./build-mc-deb-package.sh
- name: Calculate Debian Repository Metadata
run: |
source common.sh
curl -H "Authorization: Bearer ${{ secrets.ARTIFACTORY_SECRET }}" \
-X POST "https://repository.hazelcast.com/api/deb/reindex/${DEBIAN_REPO}"
- name: Install Hazelcast Management Center from DEB
run: |
source ./common.sh
wget -qO - https://repository.hazelcast.com/api/gpg/key/public | sudo apt-key add -
echo "deb ${DEBIAN_REPO_BASE_URL} ${PACKAGE_REPO} main" | sudo tee -a /etc/apt/sources.list
sudo apt update && sudo apt install hazelcast-management-center=${MC_VERSION}
/usr/lib/hazelcast-management-center/bin/hz-mc start -Dhazelcast.mc.healthCheck.enable=true > hz-mc.log 2>&1 &
- name: Check Hazelcast Management Center Health
run: |
./check-mc-health.sh
- name: Uninstall CLI from deb
run: |
source ./common.sh
sudo apt remove hazelcast-management-center
- name: Remove deb package from test repo
if: github.event_name == 'pull_request'
run: |
source ./common.sh
curl -H "Authorization: Bearer ${{ secrets.ARTIFACTORY_SECRET }}" \
-X DELETE \
"$DEBIAN_REPO_BASE_URL/hazelcast-management-center-${DEB_PACKAGE_VERSION}-all.deb"
rpm:
runs-on: ubuntu-latest
if: ${{ needs.prepare.outputs.package_types == 'all' || needs.prepare.outputs.package_types == 'rpm' }}
container: rockylinux:9
env:
MC_VERSION: ${{ needs.prepare.outputs.mc_version }}
PACKAGE_VERSION: ${{ needs.prepare.outputs.package_version }}
defaults:
run:
working-directory: ./management-center-packaging
needs: [prepare]
steps:
- name: Checkout management-center-packaging repo
uses: actions/checkout@v3
with:
path: 'management-center-packaging'
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'temurin'
- name: Install Required tools
run: |
yum install -y maven rpm-sign rpm-build wget gettext
- name: Download the distribution tar.gz file
run: |
if [[ "${MC_VERSION}" != *SNAPSHOT* ]]; then
VERSION="${MC_VERSION}"
else
VERSION=latest-snapshot
fi
MC_PACKAGE_URL="https://repository.hazelcast.com/download/management-center/hazelcast-management-center-${VERSION}.tar.gz"
echo "MC_PACKAGE_URL=$MC_PACKAGE_URL" >> $GITHUB_ENV
curl --silent --fail --location "${MC_PACKAGE_URL}" --output hazelcast-management-center-${MC_VERSION}.tar.gz
- name: Create & Sign & Upload RPM package
run: |
./build-mc-rpm-package.sh
- name: Calculate YUM Repository Metadata
run: |
pwd
ls -lah
source ./common.sh
curl -H "Authorization: Bearer ${{ secrets.ARTIFACTORY_SECRET }}" \
-X POST "https://repository.hazelcast.com/api/yum/${RPM_REPO}"
- name: Install MC from RPM
run: |
source ./common.sh
yum install -y wget
wget ${RPM_REPO_BASE_URL}/${PACKAGE_REPO}/hazelcast-rpm-${PACKAGE_REPO}.repo -O hazelcast-rpm-${PACKAGE_REPO}.repo
mv hazelcast-rpm-${PACKAGE_REPO}.repo /etc/yum.repos.d/
yum install -y hazelcast-management-center-${RPM_MC_VERSION}
/usr/lib/hazelcast-management-center/bin/hz-mc start -Dhazelcast.mc.healthCheck.enable=true > hz-mc.log 2>&1 &
- name: Check MC health
run: |
./check-mc-health.sh
- name: Uninstall CLI from rpm
run: |
source ./common.sh
yum remove -y hazelcast-management-center-${RPM_PACKAGE_VERSION}
- name: Get homebrew repository
run: |
source ./common.sh
echo "BREW_GIT_REPO_NAME=${BREW_GIT_REPO_NAME}" >> $GITHUB_ENV
- name: Remove rpm package from test repo
if: github.event_name == 'pull_request'
run: |
source ./common.sh
curl -H "Authorization: Bearer ${{ secrets.ARTIFACTORY_SECRET }}" \
-X DELETE \
"$RPM_REPO_BASE_URL/${PACKAGE_REPO}/hazelcast-management-center-${RPM_PACKAGE_VERSION}.noarch.rpm"
homebrew:
runs-on: macos-latest
if: ${{ needs.prepare.outputs.package_types == 'all' || needs.prepare.outputs.package_types == 'homebrew' }}
env:
MC_VERSION: ${{ needs.prepare.outputs.mc_version }}
PACKAGE_VERSION: ${{ needs.prepare.outputs.package_version }}
defaults:
run:
working-directory: ./management-center-packaging
needs: [prepare]
steps:
- name: Checkout management-center-packaging repo
uses: actions/checkout@v3
with:
path: 'management-center-packaging'
- name: Install up-to-date tools
run: |
brew install gnu-sed
brew install coreutils
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
sed --version
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
sha256sum --version
echo "PATH=/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" >> $GITHUB_ENV
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'temurin'
- name: Run script tests
run: |
./test.sh
- name: Get homebrew repository
run: |
source ./common.sh
echo "BREW_GIT_REPO_NAME=${BREW_GIT_REPO_NAME}" >> $GITHUB_ENV
- name: Checkout homebrew-hz repo
uses: actions/checkout@v3
with:
repository: ${{ env.BREW_GIT_REPO_NAME }}
ref: master
token: ${{ secrets.GH_PAT }}
path: 'homebrew-hz'
- name: Download the distribution tar.gz file
run: |
if [[ "${MC_VERSION}" != *SNAPSHOT* ]]; then
VERSION="${MC_VERSION}"
else
VERSION=latest-snapshot
fi
MC_PACKAGE_URL="https://repository.hazelcast.com/download/management-center/hazelcast-management-center-${VERSION}.tar.gz"
echo "MC_PACKAGE_URL=$MC_PACKAGE_URL" >> $GITHUB_ENV
curl --silent --fail --location "${MC_PACKAGE_URL}" --output hazelcast-management-center-${MC_VERSION}.tar.gz
- name: Change the artifact in homebrew-hz
run: |
./build-mc-homebrew-package.sh
- name: Commit changes & Push to homebrew-hz repo
run: |
source common.sh
cd ../homebrew-hz
git config --global user.name 'devOpsHazelcast'
git config --global user.email '[email protected]'
git add *rb
if [[ `git status --porcelain --untracked-files=no` ]]; then
git commit -am "Hazelcast Management Center ${{ env.PACKAGE_VERSION }} release"
git pull --rebase
git push
else
echo "No changes, this is probably a re-run."
fi
- name: Install Hazelcast Management Center from Homebrew
run: |
source ./common.sh
brew tap ${BREW_TAP_NAME}
brew install hazelcast-management-center@$BREW_PACKAGE_VERSION
echo "MC_PATH=$(brew --prefix hazelcast-management-center@$BREW_PACKAGE_VERSION)" >> $GITHUB_ENV
- name: Run Hazelcast Management Center
run: |
${{ env.MC_PATH }}/libexec/bin/hz-mc start -Dhazelcast.mc.healthCheck.enable=true > hz-mc.log 2>&1 &
- name: Check Hazelcast Management Center Health
run: |
./check-mc-health.sh
- name: Uninstall Hazelcast Management Center from Homebrew
run: |
source ./common.sh
brew uninstall hazelcast-management-center@$BREW_PACKAGE_VERSION