-
Notifications
You must be signed in to change notification settings - Fork 2
219 lines (207 loc) · 8.52 KB
/
build.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
name: build
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
on:
push:
tags:
- '*.*.*'
jobs:
build-publish-backend-base:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup .NET 7.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and publish
run: |
cd backend
dotnet nuget add source https://nuget.pkg.github.com/max-bytes/index.json --name "Github nuget Repository" --username "${{ github.actor }}" --password "${{ secrets.GITHUB_TOKEN }}" --store-password-in-clear-text
dotnet pack Omnikeeper.Base/Omnikeeper.Base.csproj /p:Version=${{ env.VERSION }} -c Release
dotnet nuget push "Omnikeeper.Base/bin/Release/Omnikeeper.Base.${{ env.VERSION }}.nupkg" --source "Github nuget Repository"
build-backend-vanilla: # backend docker container without plugins
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/core/backend
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: "./backend"
file: "./backend/Omnikeeper/Dockerfile"
push: true
build-args: |
version=${{ env.VERSION }}
nugetRepoUser=${{ github.actor }}
nugetRepoPassword=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-publish-frontend-okplugin-generic-json-ingest:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and publish
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOURL: npm.pkg.github.com/
PLUGIN_FOLDER: okplugin-generic-json-ingest
run: |
cd frontend/$PLUGIN_FOLDER
npm ci --legacy-peer-deps # --legacy-peer-deps is necessary because npm 7 changed the way peer dependencies are handled
cat <<'EOF' > .npmrc
//${REPOURL}:_authToken=${ACCESS_TOKEN}
@max-bytes:registry=https://npm.pkg.github.com
EOF
npm version ${{ env.VERSION }} # set version
npm publish
build-publish-frontend-okplugin-visualization:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and publish
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOURL: npm.pkg.github.com/
PLUGIN_FOLDER: okplugin-visualization
run: |
cd frontend/$PLUGIN_FOLDER
npm ci --legacy-peer-deps # --legacy-peer-deps is necessary because npm 7 changed the way peer dependencies are handled
cat <<'EOF' > .npmrc
//${REPOURL}:_authToken=${ACCESS_TOKEN}
@max-bytes:registry=https://npm.pkg.github.com
EOF
npm version ${{ env.VERSION }} # set version
npm publish
build-publish-backend-okplugins:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup .NET 7.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and publish
run: |
cd backend
function buildPublish () {
dotnet pack $1/$1.csproj /p:Version=${{ env.VERSION }} -c Release
# pushing seems to not work sometimes, see https://github.com/NuGet/Home/issues/8580#issuecomment-714501802
dotnet nuget push "$1/bin/Release/$1.${{ env.VERSION }}.nupkg" --source "https://nuget.pkg.github.com/max-bytes/index.json" -k "${{ secrets.GITHUB_TOKEN }}" --skip-duplicate
}
buildPublish OKPluginGenericJSONIngest
buildPublish OKPluginInsightDiscoveryScanIngest
#buildPublish OKPluginOIASharepoint
#buildPublish OKPluginOIAOmnikeeper
#buildPublish OKPluginOIAKeycloak
#buildPublish OKPluginCLBMonitoring
#buildPublish OKPluginCLBNaemonVariableResolution
#buildPublish OKPluginCLBVariableRendering
#buildPublish OKPluginCLBNaemonConfig
buildPublish OKPluginAnsibleInventoryScanIngest
buildPublish OKPluginActiveDirectoryXMLIngest
buildPublish OKPluginVisualization
build-swagger-definition:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build
run: |
# TODO, HACK: we haven't found a good way to generate client APIs for plugin endpoints, so we fallback to a static swagger definition file
cp clients/source/omnikeeper_static.json omnikeeper.json
# HACK: commented out code for dynamically creating a swagger definition file
# cd backend
# dotnet nuget remove source "nuget Repository" # HACK: we need to remove the internal repo, nuget is stupid :(
# dotnet build "Omnikeeper/Omnikeeper.csproj" -c Release
# cd Omnikeeper
# dotnet tool restore
# dotnet swagger tofile --output ../../omnikeeper.json ./bin/Release/net7.0/Omnikeeper.dll v1
- uses: actions/upload-artifact@v2
with:
name: omnikeeper-swagger-json
path: omnikeeper.json
run-perf-tests:
runs-on: ubuntu-20.04
steps:
- name: "Invoke perf-tests workflow"
uses: benc-uk/workflow-dispatch@v1
with:
workflow: run-perf-tests
token: ${{ secrets.PAT }}
run-tests:
runs-on: ubuntu-20.04
steps:
- name: "Invoke tests workflow"
uses: benc-uk/workflow-dispatch@v1
with:
workflow: run-tests
token: ${{ secrets.PAT }}
publish-client-libraries:
runs-on: ubuntu-20.04
needs: build-swagger-definition
env:
ACCESS_TOKEN_REPO_CLIENT_GO: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- uses: actions/download-artifact@v2
with:
name: omnikeeper-swagger-json
- name: Build
run: |
bash clients/scripts/go/generate_publish.sh github.com omnikeeper.json ${{ env.VERSION }} "max-bytes" "${{ secrets.CLIENT_LIBRARY_DEPLOY_TOKEN_GO }}"
bash clients/scripts/java/generate_publish.sh github.com omnikeeper.json ${{ env.VERSION }} "max-bytes" "${{ secrets.CLIENT_LIBRARY_DEPLOY_TOKEN_JAVA }}"
bash clients/scripts/powershell/generate_publish.sh github.com omnikeeper.json ${{ env.VERSION }} "max-bytes" "${{ secrets.CLIENT_LIBRARY_DEPLOY_TOKEN_POWERSHELL }}"
call-backend-package-variants:
runs-on: ubuntu-20.04
needs: [build-backend-vanilla, build-publish-backend-okplugins]
steps:
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: "Invoke backend packaging variants"
uses: benc-uk/workflow-dispatch@v1
with:
workflow: call-backend-package-variants
token: ${{ secrets.PAT }}
inputs: '{ "baseVersion": "${{ env.VERSION }}" }'
call-frontend-package-variants:
runs-on: ubuntu-20.04
needs: [build-publish-frontend-okplugin-generic-json-ingest, build-publish-frontend-okplugin-visualization]
steps:
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: "Invoke frontend packaging variants"
uses: benc-uk/workflow-dispatch@v1
with:
workflow: call-frontend-package-variants
token: ${{ secrets.PAT }}
inputs: '{ "baseVersion": "${{ env.VERSION }}" }'