-
Notifications
You must be signed in to change notification settings - Fork 4
240 lines (239 loc) · 7.23 KB
/
CI-CD.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
name: Revue CI and CD
on:
push:
paths-ignore:
- 'README.md'
- 'CHANGELOG.md'
- 'renovate.json'
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'main') }}
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- macos-12
- windows-2022
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build
run: ./gradlew npmBuild build --info
- name: Test
run: ./gradlew auth:npmTest user:npmTest alarm:npmTest device:npmTest log:npmTest notification:npmTest location:npmTest --info --parallel
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Check format
run: ./gradlew format npmFormat --info
- name: Check lint
run: ./gradlew npmLint --info
build-website:
defaults:
run:
working-directory: docs/website
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- name: Build the website
run: |
npm install
npm run build
cd ../..
./gradlew generate-openapi-website generate-openapi-index-page
mv build/openapi docs/website/build
- name: Build AsyncAPI
run: |
cd ../api/asyncapi
npm install
npx -p @asyncapi/cli asyncapi generate fromTemplate ./specification.yml @asyncapi/html-template -o ./build/asyncapi --force-write
mv ./build/asyncapi/ ../../website/build
- uses: actions/[email protected]
with:
name: website
path: docs/website/build
compute-next-version:
needs:
- build
- style
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
outputs:
will-release: ${{ steps.compute-next-version.outputs.will-release }}
next-version: ${{ steps.compute-next-version.outputs.next-version }}
steps:
- name: Checkout repo
uses: actions/[email protected]
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '21'
cache: 'npm'
- name: Pre-compute the next version
id: compute-next-version
uses: nicolasfara/[email protected]
with:
github-token: ${{ secrets.GH_TOKEN }}
- name: Use the next version
run: |
echo "Will release: ${{ steps.compute-next-version.outputs.will-release }}"
echo "The next version is ${{ steps.compute-next-version.outputs.next-version }}"
release:
needs:
- compute-next-version
- build-website
runs-on: ubuntu-latest
concurrency:
# Only one release job at a time per branch, strictly sequential.
group: release-${{ github.event.number || github.ref }}
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
deploy-website:
runs-on: ubuntu-latest
needs:
- build-website
- release
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
) && fromJSON(needs.compute-next-version.outputs.will-release)
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
name: website
path: docs/website/build
- uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GH_TOKEN }}
folder: docs/website/build
docker:
name: Push ${{ matrix.image }} image to docker hub
concurrency:
group: release-${{ github.event.number || github.ref }}-docker-${{ matrix.image }}
strategy:
fail-fast: false
matrix:
image:
- alarm
- auth
- device
- frontend
- location
- log
- monitoring
- notification
- recognition
- user
needs:
- compute-next-version
- release
runs-on: ubuntu-latest
env:
DOCKER_BUILD: true
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
) && fromJSON(needs.compute-next-version.outputs.will-release)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/[email protected]
env:
releaseTag: ${{
fromJSON(needs.compute-next-version.outputs.will-release)
&& needs.compute-next-version.outputs.next-version || 'ci'
}}
with:
context: .
file: ./${{ matrix.image }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ fromJSON(needs.compute-next-version.outputs.will-release) }}
tags: |
letsdothisshared/revue-${{ matrix.image }}:${{ env.releaseTag }}
letsdothisshared/revue-${{ matrix.image }}:latest
success:
runs-on: ubuntu-latest
needs:
- build
- style
- build-website
- release
- docker
- compute-next-version
- deploy-website
# Always run this job, even if the previous jobs failed
if: >-
always() && (failure() || !contains(join(needs.*.result, ','), 'cancelled'))
steps:
- name: None of the dependant jobs should fail
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}