forked from intersystems/ipm
-
Notifications
You must be signed in to change notification settings - Fork 0
286 lines (286 loc) · 12.3 KB
/
main.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
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
release:
types:
- released
env:
name: |
irishealth-community
iris-community
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
images: ${{ steps.set-matrix.outputs.images }}
main: ${{ steps.set-matrix.outputs.main }}
version: ${{ steps.version.outputs.number }}
steps:
- uses: actions/checkout@master
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Images list
id: set-matrix
run: |
images=""
for n in $name; do
tags=$(curl -su ":" https://containers.intersystems.com/v2/intersystems/${n}/tags/list | jq -r '.tags[]' | awk '!/(-linux)|([1-4]-preview)|(-em)|(-cd)/' | awk '!/\.[1-4]\./' | sort | uniq)
for tag in $tags
do
# Skip irishealth-community due to bad interaction with ZPM document type
# Also skip 2023.2 because the license has expired
if [ "$n" = "irishealth-community" -a "$tag" = "2023.3" -o "$tag" = "2023.2" ];
then
continue
fi
images+='"'${n}:${tag}'",';
done
done;
echo images="[${images%?}]" >> $GITHUB_OUTPUT
echo main=${images%%,*} >> $GITHUB_OUTPUT
- name: Setup version
id: version
run: |
VERSION=`grep -oPm1 "(?<=<Version>)[^<]+" module.xml | cut -d- -f1`
git tag -l | cat
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }} && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f5)+1))
echo number=${VERSION} >> $GITHUB_OUTPUT
build:
timeout-minutes: 20
needs:
- prepare
strategy:
fail-fast: false
matrix:
image: ${{ fromJson(needs.prepare.outputs.images) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set image
id: image
run: |
IMAGE=containers.intersystems.com/intersystems/${{ matrix.image }}
echo name=${IMAGE} >> $GITHUB_OUTPUT
FLAGS=
[[ $IMAGE == *:2021.* ]] && FLAGS=' --check-caps false'
[[ $IMAGE == *:2022.1.* ]] && FLAGS=' --check-caps false'
echo flags=${FLAGS} >> $GITHUB_OUTPUT
- name: Setup version
id: version
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
sed -i -E "s/<Version>(.*)<\/Version>/<Version>${VERSION}<\/Version>/" module.xml
cat module.xml
echo number=${VERSION} >> $GITHUB_OUTPUT
- name: Build
uses: docker/build-push-action@v4
with:
context: .
push: false
load: true
tags: zpm
build-args: BASE=${{ steps.image.outputs.name }}
- name: Run temporary registry
timeout-minutes: 15
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com --username ${{ github.actor }} --password-stdin
docker pull docker.pkg.github.com/intersystems-community/zpm-registry/zpm-registry
docker network create zpm
docker run --rm -d \
--network zpm \
--name registry \
-p 52773:52773 \
--network-alias registry \
docker.pkg.github.com/intersystems-community/zpm-registry/zpm-registry \
-a "iris session iris -U%SYS '##class(Security.Users).UnExpireUserPasswords(\"*\")'"
REGISTRY=`docker ps -lq`
sleep 5; docker exec $REGISTRY /usr/irissys/dev/Cloud/ICM/waitISC.sh
docker logs $REGISTRY
- name: Test and Verify
timeout-minutes: 15
run: |
docker run --network zpm -d --rm \
-e TEST_REGISTRY=http://registry:52773/registry/ \
-e TEST_REGISTRY_USER=admin \
-e TEST_REGISTRY_PASSWORD=SYS \
-v `pwd`:/home/irisowner/zpm/ \
zpm ${{ steps.image.outputs.flags }}
CONTAINER=`docker ps -lq`
sleep 5; docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
/bin/echo -e '' \
'zpm "list":1\n' \
'zpm "test zpm -v -only":1\n' \
'zpm "verify zpm -v -only":1' \
'halt\n' \
| docker exec -i $CONTAINER iris session iris -U%SYS
docker stop $CONTAINER
- name: Restart temporary registry
timeout-minutes: 15
run: |
docker rm -f registry || true
docker run --rm -d \
--network zpm \
--name registry \
-p 52773:52773 \
--network-alias registry \
docker.pkg.github.com/intersystems-community/zpm-registry/zpm-registry \
-a "iris session iris -U%SYS '##class(Security.Users).UnExpireUserPasswords(\"*\")'"
REGISTRY=`docker ps -lq`
sleep 5; docker exec $REGISTRY /usr/irissys/dev/Cloud/ICM/waitISC.sh
docker logs $REGISTRY
- name: Test and publish to temporary registry
timeout-minutes: 15
run: |
docker run --network zpm -d --rm -v `pwd`:/home/irisowner/zpm/ zpm ${{ steps.image.outputs.flags }}
CONTAINER=`docker ps -lq`
sleep 5; docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
/bin/echo -e '' \
'zpm "repo -r -name registry -url https://pm.community.intersystems.com/":1\n' \
'zpm "repo -list":1\n' \
'zpm "install dsw":1\n' \
'zpm "install sslclient":1\n' \
'zpm "list":1\n' \
'zpm "repo -r -name registry -url ""http://registry:52773/registry/"" -username admin -password SYS":1\n' \
'zpm "publish zpm -v":1' \
'zpm "publish sslclient -v":1' \
'zpm "search":1' \
'halt\n' \
| docker exec -i $CONTAINER iris session iris -U%SYS
docker stop $CONTAINER
- name: Clean install current version and test new one. (Permitted to fail on 2023.1+)
timeout-minutes: 15
run: |
curl http://localhost:52773/registry/packages/-/all | jq
curl http://localhost:52773/registry/packages/zpm/ | jq
wget https://pm.community.intersystems.com/packages/zpm/latest/installer -O /tmp/zpm.xml
docker run --network zpm --rm -d -v /tmp/zpm.xml:/home/irisowner/zpm.xml ${{ steps.image.outputs.name }} ${{ steps.image.outputs.flags }}
CONTAINER=`docker ps -lq`
sleep 5; docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
/bin/echo -e '' \
'set sc = ##class(%SYSTEM.OBJ).Load("/home/irisowner/zpm.xml", "ck")\n' \
'if +sc=0 { halt:$System.Version.GetMajor()>=2023 do ##class(%SYSTEM.Process).Terminate(,1) }\n' \
'zpm "list":1\n' \
'zpm "repo -r -name registry -url ""http://registry:52773/registry/"" -username admin -password SYS":1\n' \
'zpm "repo -list"\n' \
'zpm "search":1\n' \
'zpm "install sslclient":1\n' \
'zpm "install zpm -v":1\n' \
'zpm "list":1\n' \
'zpm "version":1\n' \
'halt\n' \
| docker exec -i $CONTAINER iris session iris -U%SYS
docker stop $CONTAINER
- name: Clean install and test
timeout-minutes: 15
run: |
wget http://localhost:52773/registry/packages/zpm/latest/installer -O /tmp/zpm.xml
docker run --network zpm --rm -d -v /tmp/zpm.xml:/home/irisowner/zpm.xml ${{ steps.image.outputs.name }} ${{ steps.image.outputs.flags }}
CONTAINER=`docker ps -lq`
sleep 5; docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
/bin/echo -e '' \
'set sc = ##class(%SYSTEM.OBJ).Load("/home/irisowner/zpm.xml", "ck")\n' \
'if +sc=0 do ##class(%SYSTEM.Process).Terminate(,1)\n' \
'zpm "list":1\n' \
'zpm "repo -r -name registry -url https://pm.community.intersystems.com/":1\n' \
'zpm "install dsw":1\n' \
'zpm "list":1\n' \
'halt\n' \
| docker exec -i $CONTAINER iris session iris -U%SYS
docker stop $CONTAINER
- name: Prepare XML Installer
timeout-minutes: 15
run: |
wget http://localhost:52773/registry/packages/zpm/latest/installer -O zpm-${{ needs.prepare.outputs.version }}.xml
- name: Stop temporary registry
run: |
docker stop registry
docker network rm zpm
- uses: actions/upload-artifact@v3
if: matrix.image == ${{ needs.prepare.outputs.main }}
with:
name: zpm-${{ needs.prepare.outputs.version }}
path: zpm-${{ needs.prepare.outputs.version }}.xml
release:
runs-on: ubuntu-latest
if: github.event.repository.fork == false
needs:
- prepare
- build
steps:
- uses: actions/checkout@master
if: github.event_name == 'release'
with:
ref: master
- uses: actions/download-artifact@v3
with:
name: zpm-${{ needs.prepare.outputs.version }}
- name: Create Beta Release
id: create_release
uses: actions/create-release@v1
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.prepare.outputs.version }}
release_name: v${{ needs.prepare.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
- name: Upload Beta Release Asset
uses: actions/upload-release-asset@v1
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: zpm-${{ needs.prepare.outputs.version }}.xml
asset_name: zpm-${{ needs.prepare.outputs.version }}.xml
asset_content_type: text/xml
- name: Publish release
if: github.event_name == 'release'
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
sed -i -E "s/<Version>(.*)<\/Version>/<Version>${VERSION}<\/Version>/" module.xml
cat module.xml
docker run -d --rm -v `pwd`:/home/irisowner/zpm/ containers.intersystems.com/intersystems/${{ needs.prepare.outputs.main }} --check-caps false
CONTAINER=`docker ps -lq`
sleep 5; docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
/bin/echo -e '' \
'set sc=##class(%SYSTEM.OBJ).Load("/home/irisowner/zpm/Installer.cls","ck")' \
'set sc=##class(%ZPM.Installer).setup("/home/irisowner/zpm/",3)' \
'zpm "repo -r -name registry -url ""https://pm.community.intersystems.com/"" -username ${{ secrets.REGISTRY_USERNAME }} -password ${{ secrets.REGISTRY_PASSWORD }}":1\n' \
'zpm "publish zpm -v":1' \
'halt\n' \
| docker exec -i $CONTAINER iris session iris -U%SYS
docker stop $CONTAINER
- name: Upload Public Release Asset
uses: actions/upload-release-asset@v1
if: github.event_name == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: zpm-${{ needs.prepare.outputs.version }}.xml
asset_name: zpm-${{ needs.prepare.outputs.version }}.xml
asset_content_type: text/xml
- name: Bump Release number
if: github.event_name == 'release'
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
NEXT_VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
[ $NEXT_VERSION != $VERSION ] && (
sed -i -E "s/<Version>(.*)<\/Version>/<Version>${NEXT_VERSION/v/}-SNAPSHOT<\/Version>/" module.xml
cat module.xml
git config --global user.name 'ProjectBot'
git config --global user.email '[email protected]'
git add module.xml
git commit -m 'auto bump version with release'
git push
)