-
Notifications
You must be signed in to change notification settings - Fork 45
225 lines (178 loc) · 6.27 KB
/
test-build-publish.yaml
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
name: Test, Build and Publish Projects
on:
workflow_dispatch:
pull_request:
branches: [master]
push:
tags:
- "v**"
- "ai-beta.**"
branches:
- master
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
GITHUB_CR: ghcr.io
jobs:
test-version-packages:
name: Test and version packages
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
# changelog generation requires full history
# to track each changelog file to its submission commit
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: pnpm/[email protected]
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Prepare dev libs and code
run: pnpm prepareDev
- name: Lint code
run: pnpm lint
- name: Generate SSH key pairs for test
run: ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N ""
- name: Start dev env for db testing
run: pnpm devenv
- name: Check running containers
run: docker ps
- name: Wait for ports
uses: ifaxity/[email protected]
with:
log: true
verbose: true
resource: "tcp:localhost:3306 tcp:localhost:6379 tcp:localhost:389 tcp:localhost:6000 tcp:localhost:6001 tcp:localhost:6002"
- name: Run tests
run: pnpm test:ci
- name: Upload test converage
uses: codecov/codecov-action@v4
with:
files: ./libs/auth/coverage/lcov.info,./libs/ssh/coverage/lcov.info,./libs/libconfig/coverage/lcov.info,./libs/decimal/coverage/lcov.info,./libs/server/coverage/lcov.info,./apps/cli/coverage/lcov.info,./apps/auth/coverage/lcov.info,./apps/mis-server/coverage/lcov.info,./apps/portal-server/coverage/lcov.info,./apps/gateway/coverage/lcov.info,./apps/audit-server/coverage/lcov.info
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
if: github.ref == 'refs/heads/master'
with:
version: pnpm ci:version
publish: pnpm ci:publish
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
openscow-cli:
needs: test-version-packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: Install dependencies for openscow-cli
run: pnpm i --frozen-lockfile --filter @scow/cli...
- name: Build openscow-cli
run: pnpm build "--filter=@scow/cli"
- name: Archive openscow-cli-x64
uses: actions/upload-artifact@v4
with:
name: openscow-cli-x64
path: apps/cli/exe/cli-x64
- name: Archive openscow-cli-arm64
uses: actions/upload-artifact@v4
with:
name: openscow-cli-arm64
path: apps/cli/exe/cli-arm64
build-images:
needs: test-version-packages
if: github.event.pull_request.head.repo.fork == false
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- name: scow
file: scow
build_args: ""
- name: docs
file: docs
build_args: BASE_PATH=/OpenSCOW/
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the GitHub Container registry
uses: docker/login-action@1f36f5b7a2d2f7bfd524795fc966e6d88c37baa9
with:
registry: ${{ env.GITHUB_CR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GITHUB_CR }}/${{ github.repository }}/${{ matrix.name }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: ${{ matrix.build_args }}
tags: ${{ steps.meta.outputs.tags }}
file: docker/Dockerfile.${{ matrix.file }}
labels: ${{ steps.meta.outputs.labels }}
# only build arm64 in tag commits or branches with name starting with `arm-`
platforms: linux/amd64${{ (github.ref_type == 'tag' || startsWith(github.ref_name, 'arm-')) && ',linux/arm64' || '' }}
release:
runs-on: ubuntu-latest
needs:
- openscow-cli
- build-images
if: github.ref_type == 'tag'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download cli-x64
uses: actions/download-artifact@v4
with:
name: openscow-cli-x64
path: release/openscow-cli
- name: Download cli-arm64
uses: actions/download-artifact@v4
with:
name: openscow-cli-arm64
path: release/openscow-cli
- name: Display structure of downloaded files
run: ls -R
working-directory: release
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: OpenSCOW ${{ startsWith(github.ref_name, 'ai-') && format('AI Beta {0}', github.ref_name) || github.ref_name }}
body_path: ${{ !startsWith(github.ref_name, 'ai-') && format('changelogs/{0}.md', github.ref_name) || null }}
generate_release_notes: ${{ startsWith(github.ref_name, 'ai-') }}
prerelease: ${{ startsWith(github.ref_name, 'ai-') }}
files: |
release/openscow-cli/cli-x64
release/openscow-cli/cli-arm64
- name: Send Notification Request
run: |
curl -X POST ${{ secrets.RELEASE_SERVICE_ADDRESS }}/version/success \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.RELEASE_API_KEY }}" \
-d '{
"repo": "OpenSCOW"
}'