-
Notifications
You must be signed in to change notification settings - Fork 6
320 lines (274 loc) · 10.1 KB
/
publish_agent.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
name: Publish Agent
on:
workflow_dispatch:
inputs:
environment:
description: "Manual environment to run (staging | prod)"
required: false
type: string
agent_version:
description: "Build version example: v2.0.3"
required: true
type: string
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
jobs:
### SET ENV ###
set_env:
runs-on: ubuntu-latest
name: Set Environment
steps:
- name: Set environment base on input
id: set_env
run: echo "Exposing environment vars to reusable workflow"
outputs:
ENV: ${{ inputs.environment }}
### BUILD ###
build:
name: Build
runs-on: ${{ matrix.os }}
env:
AGENT_VERSION: ${{ inputs.agent_version }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-22.04
- macos-13
- macos-14
- windows-2022
node-version:
- 20.9.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm ci
- name: Set BUILD_VERSION environment variable
run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
cp $(command -v node) agent
npx postject agent NODE_SEA_BLOB agent.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
chmod +x agent
mkdir bin
mv agent bin/cli-linux-x64
npm run afterbuild
ls -al bin
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'macos-13' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
cp $(command -v node) agent
codesign --remove-signature agent
npx postject agent NODE_SEA_BLOB agent.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_SEA
# codesign --sign - agent
mkdir bin
chmod +x agent
mv agent bin/cli-macos-x64
npm run afterbuild
ls -al bin
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'macos-14' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
cp $(command -v node) agent
codesign --remove-signature agent
npx postject agent NODE_SEA_BLOB agent.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_SEA
# codesign --sign - agent
mkdir bin
chmod +x agent
mv agent bin/cli-macos-x64
npm run afterbuild
ls -al bin
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'windows-2022' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
node -e "require('fs').copyFileSync(process.execPath, 'agent.exe')"
# $signtool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe"
# $signtool remove /s agent.exe
npx postject agent.exe NODE_SEA_BLOB agent.blob `
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
# $signtool sign /fd SHA256 agent.exe
# chmod +x agent
md bin -ea 0
cp agent.exe bin/cli-win-x64.exe
cp agent.exe bin/cli-win-x86.exe
npm run afterbuild
# ls -al
- name: Upload Windows x64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-2022' }}
with:
name: katalon-agent-win-x64-${{ env.AGENT_VERSION }}
path: |
bin/cli-win-x64.exe
bin/nssm.exe
bin/*.bat
- name: Upload Windows x86 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-2022' }}
with:
name: katalon-agent-win-x86-${{ env.AGENT_VERSION }}
path: |
bin/cli-win-x86.exe
bin/nssm.exe
bin/*.bat
- name: Upload Linux x64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-22.04' }}
with:
name: katalon-agent-linux-x64-${{ env.AGENT_VERSION }}
path: |
bin/cli-linux-x64
bin/*.sh
- name: Upload MacOS x64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'macos-13' }}
with:
name: katalon-agent-macos-x64-${{ env.AGENT_VERSION }}
path: |
bin/cli-macos-x64
bin/start.sh
- name: Upload MacOS ARM64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'macos-14' }}
with:
name: katalon-agent-macos-arm64-${{ env.AGENT_VERSION }}
path: |
bin/cli-macos-arm64
bin/start.sh
### RELEASE ###
release:
name: Release
environment: ${{ needs.set_env.outputs.ENV }}
env:
AGENT_VERSION: ${{ inputs.agent_version }}
needs: [set_env, build]
if: ${{ needs.set_env.outputs.ENV == 'prod' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 20.9.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm ci
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: .
- name: Add execute permission to downloaded artifacts
run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/*
- name: Set BUILD_VERSION environment variable
run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV
- name: Change Package.json version for release
run: sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json
- name: Package artifacts for release
env:
GZIP: -9
run: |
set -x
mkdir -p packages
ls -la
zip -9 -j packages/katalon-agent-win-x64-$AGENT_VERSION.zip katalon-agent-win-x64-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-win-x86-$AGENT_VERSION.zip katalon-agent-win-x86-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-linux-x64-$AGENT_VERSION.zip katalon-agent-linux-x64-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-macos-x64-$AGENT_VERSION.zip katalon-agent-macos-x64-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-macos-arm64-$AGENT_VERSION.zip katalon-agent-macos-arm64-$AGENT_VERSION/*
cd katalon-agent-linux-x64-$AGENT_VERSION
tar cvzf ../packages/katalon-agent-linux-x64-$AGENT_VERSION.tar.gz *
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run release
### DEPLOY ###
deploy:
name: Deploy cloud agent
environment: ${{ needs.set_env.outputs.ENV }}
env:
AGENT_VERSION: ${{ inputs.agent_version }}
needs: [set_env, build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm install --only dev
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/katalon-github-oidc-federation
role-session-name: github-actions
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: 'no'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: .
- name: Add execute permission to downloaded artifacts
run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/*
- name: Deploy to s3 prod
if: ${{ needs.set_env.outputs.ENV == 'prod' }}
run: |
ls -laR
aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }}/katalon-agent/$AGENT_VERSION/cli-linux-x64
commit:
runs-on: ubuntu-latest
needs: [set_env, build, deploy, release]
name: Commit Code
env:
AGENT_VERSION: ${{ inputs.agent_version }}
environment: ${{ needs.set_env.outputs.ENV }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set BUILD_VERSION environment variable
run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV
- name: Change Package.json version for release
run: sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json
### Commit code
- name: Deploy to GitOps
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update version to ${{ env.AGENT_VERSION }}
# Optional commit user and author settings
commit_user_name: github-cloudops-bot # defaults to "github-actions[bot]"
commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: Author <[email protected]> # defaults to author of the commit that triggered the run