-
Notifications
You must be signed in to change notification settings - Fork 22
327 lines (284 loc) · 11.6 KB
/
publish-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
name: Publish Hazelcast OS & EE packages
on:
push:
# Push to master updates the latest snapshot (HZ_VERSION taken from pom.xml)
branches:
- master
# Push of a matching tag (v*, e.g. v5.0.2) starts build with
# - HZ_VERSION extracted from pom.xml
# - PACKAGE_VERSION extracted from the tag
tags:
- 'v*'
pull_request:
types: [ opened, synchronize, edited ]
workflow_dispatch:
inputs:
HZ_VERSION:
description: 'Version of Hazelcast 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"
JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}
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:
HZ_VERSION: ${{ github.event.inputs.HZ_VERSION }}
defaults:
run:
working-directory: ./hazelcast-packaging
outputs:
hz_version: ${{ steps.hz_version.outputs.hz_version }}
package_version: ${{ steps.package_version.outputs.package_version }}
package_types: ${{ github.event.inputs.package_types || 'all' }}
steps:
- name: Checkout hazelcast-packaging repo
uses: actions/checkout@v4
with:
path: 'hazelcast-packaging'
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Set HZ_VERSION
id: hz_version
run: |
if [ -z "${{ env.HZ_VERSION }}" ]; then
HZ_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
fi
echo "HZ_VERSION=$HZ_VERSION" >> $GITHUB_ENV
echo "hz_version=$HZ_VERSION" >> $GITHUB_OUTPUT
- 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 HZ_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.HZ_VERSION }}
fi
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
deb:
runs-on: ubuntu-latest
if: ${{ needs.prepare.outputs.package_types == 'all' || needs.prepare.outputs.package_types == 'deb' }}
strategy:
fail-fast: false
matrix:
distribution: [ 'hazelcast', 'hazelcast-enterprise' ]
env:
HZ_VERSION: ${{ needs.prepare.outputs.hz_version }}
PACKAGE_VERSION: ${{ needs.prepare.outputs.package_version }}
HZ_DISTRIBUTION: ${{ matrix.distribution }}
defaults:
run:
working-directory: ./hazelcast-packaging
needs: [prepare]
steps:
- name: Checkout hazelcast-packaging repo
uses: actions/checkout@v4
with:
path: 'hazelcast-packaging'
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Download the distribution tar.gz file
run: |
HZ_PACKAGE_URL=$(mvn --batch-mode dependency:copy -Dartifact=com.hazelcast:${HZ_DISTRIBUTION}-distribution:${HZ_VERSION}:tar.gz -DoutputDirectory=./ -Dmdep.useBaseVersion=true | grep 'Downloaded from' | grep -Eo "https://[^ >]+${HZ_DISTRIBUTION}-distribution-.*.tar.gz")
echo "HZ_PACKAGE_URL=$HZ_PACKAGE_URL" >> $GITHUB_ENV
- name: Create & Upload DEB package
run: |
./build-hazelcast-deb-package.sh
- name: Calculate Debian Repository Metadata
run: |
source common.sh
curl --fail-with-body --retry 3 --retry-delay 10 -H "Authorization: Bearer ${{ secrets.JFROG_TOKEN }}" \
-X POST "https://repository.hazelcast.com/api/deb/reindex/${DEBIAN_REPO}"
- name: Install Hazelcast from deb
run: |
source ./common.sh
wget -qO - https://repository.hazelcast.com/api/gpg/key/public | gpg --dearmor | sudo tee /usr/share/keyrings/hazelcast-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/hazelcast-archive-keyring.gpg] ${DEBIAN_REPO_BASE_URL} ${PACKAGE_REPO} main" | sudo tee -a /etc/apt/sources.list
sudo apt update && sudo apt install ${{ env.HZ_DISTRIBUTION}}=${HZ_VERSION}
HAZELCAST_CONFIG="$(pwd)/config/integration-test-hazelcast.yaml" hz-start > hz.log 2>&1 &
- name: Check Hazelcast health
run: |
./check-hazelcast-health.sh
- name: Uninstall Hazelcast from deb
run: |
source ./common.sh
sudo apt remove ${{ env.HZ_DISTRIBUTION}}
- name: Remove deb package from test repo
if: github.event_name == 'pull_request'
run: |
source ./common.sh
curl -H "Authorization: Bearer ${{ secrets.JFROG_TOKEN }}" \
-X DELETE \
"$DEBIAN_REPO_BASE_URL/${HZ_DISTRIBUTION}-${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
strategy:
fail-fast: false
matrix:
distribution: [ 'hazelcast', 'hazelcast-enterprise' ]
env:
HZ_VERSION: ${{ needs.prepare.outputs.hz_version }}
PACKAGE_VERSION: ${{ needs.prepare.outputs.package_version }}
HZ_DISTRIBUTION: ${{ matrix.distribution }}
defaults:
run:
working-directory: ./hazelcast-packaging
needs: [prepare]
steps:
- name: Checkout hazelcast-packaging repo
uses: actions/checkout@v4
with:
path: 'hazelcast-packaging'
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Install Required tools
run: |
yum install -y maven rpm-sign rpm-build wget gettext systemd-rpm-macros
- name: Download the distribution tar.gz file
run: |
HZ_PACKAGE_URL=$(mvn --batch-mode dependency:copy -Dartifact=com.hazelcast:${HZ_DISTRIBUTION}-distribution:${HZ_VERSION}:tar.gz -DoutputDirectory=./ -Dmdep.useBaseVersion=true | grep 'Downloaded from' | grep -Eo "https://[^ >]+${HZ_DISTRIBUTION}-distribution-.*.tar.gz")
echo "HZ_PACKAGE_URL=$HZ_PACKAGE_URL" >> $GITHUB_ENV
- name: Create & Sign & Upload RPM package
run: |
./build-hazelcast-rpm-package.sh
- name: Calculate YUM Repository Metadata
run: |
pwd
ls -lah
source ./common.sh
curl --fail-with-body --retry 3 --retry-delay 10 -H "Authorization: Bearer ${{ secrets.JFROG_TOKEN }}" \
-X POST "https://repository.hazelcast.com/api/yum/${RPM_REPO}"
- name: Install Hazelcast from rpm
run: |
source ./common.sh
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 ${{ env.HZ_DISTRIBUTION}}-${RPM_HZ_VERSION}
HAZELCAST_CONFIG="$(pwd)/config/integration-test-hazelcast.yaml" hz-start > hz.log 2>&1 &
- name: Check Hazelcast health
run: |
./check-hazelcast-health.sh
- name: Uninstall Hazelcast from rpm
run: |
source ./common.sh
yum remove -y ${{ env.HZ_DISTRIBUTION}}-${RPM_PACKAGE_VERSION}
- name: Remove rpm package from test repo
if: github.event_name == 'pull_request'
run: |
source ./common.sh
curl -H "Authorization: Bearer ${{ secrets.JFROG_TOKEN }}" \
-X DELETE \
"$RPM_REPO_BASE_URL/${PACKAGE_REPO}/${HZ_DISTRIBUTION}-${RPM_PACKAGE_VERSION}.noarch.rpm"
homebrew:
runs-on: macos-latest
if: ${{ needs.prepare.outputs.package_types == 'all' || needs.prepare.outputs.package_types == 'homebrew' }}
strategy:
fail-fast: false
matrix:
distribution: [ 'hazelcast', 'hazelcast-enterprise' ]
env:
HZ_VERSION: ${{ needs.prepare.outputs.hz_version }}
PACKAGE_VERSION: ${{ needs.prepare.outputs.package_version }}
HZ_DISTRIBUTION: ${{ matrix.distribution }}
defaults:
run:
working-directory: ./hazelcast-packaging
needs: [prepare]
steps:
- name: Checkout hazelcast-packaging repo
uses: actions/checkout@v4
with:
path: 'hazelcast-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: Run script tests
run: |
./test.sh
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Download the distribution tar.gz file
run: |
HZ_PACKAGE_URL=$(mvn --batch-mode dependency:copy -Dartifact=com.hazelcast:${HZ_DISTRIBUTION}-distribution:${HZ_VERSION}:tar.gz -DoutputDirectory=./ -Dmdep.useBaseVersion=true | grep 'Downloaded from' | grep -Eo "https://[^ >]+${HZ_DISTRIBUTION}-distribution-.*.tar.gz")
echo "HZ_PACKAGE_URL=$HZ_PACKAGE_URL" >> $GITHUB_ENV
- 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@v4
with:
repository: ${{ env.BREW_GIT_REPO_NAME }}
ref: master
token: ${{ secrets.DEVOPS_SECRET }}
path: 'homebrew-hz'
- name: Change the artifact in homebrew-hz
run: |
./build-hazelcast-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 'devops@hazelcast.com'
git add *.rb
if [[ `git status --porcelain --untracked-files=no` ]]; then
git commit -am "Hazelcast Homebrew Package ${{ env.PACKAGE_VERSION }} release"
git pull --rebase
git push
else
echo "No changes, this is probably a re-run."
fi
- name: Install Hazelcast from Homebrew
run: |
source ./common.sh
brew tap ${BREW_TAP_NAME}
brew install ${{ env.HZ_DISTRIBUTION}}@$BREW_PACKAGE_VERSION
- name: Run Hazelcast
run: HAZELCAST_CONFIG="$(pwd)/config/integration-test-hazelcast.yaml" hz-start > hz.log 2>&1 &
- name: Check Hazelcast health
run: |
./check-hazelcast-health.sh
- name: Uninstall Hazelcast from homebrew
run: |
source ./common.sh
brew uninstall ${{ env.HZ_DISTRIBUTION}}@$BREW_PACKAGE_VERSION