-
Notifications
You must be signed in to change notification settings - Fork 0
243 lines (206 loc) · 8.71 KB
/
build_simpleworld.yml
File metadata and controls
243 lines (206 loc) · 8.71 KB
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
name: BUILD SimpleWorld UAT
on:
workflow_call:
inputs:
release_version:
required: true
type: string
secrets:
ST_DOCKER_USER:
required: true
ST_DOCKER_PASSWORD:
required: true
AZURE_CONTAINER_REGISTRY:
required: true
UAT_GIT_TOKEN:
required: true
NUGET_AUTH_TOKEN:
required: true
jobs:
build:
runs-on: self-hosted
env:
DOTNET_INSTALL_DIR: "/home/monfex"
steps:
- uses: actions/checkout@v3
- name: Update TargetFramework and Docker base image
run: |
python3 - << 'PY'
from pathlib import Path
ROOT = Path(".").resolve()
TF_OLD = "<TargetFramework>net8.0</TargetFramework>"
TF_NEW = "<TargetFramework>net10.0</TargetFramework>"
DOCKER_OLD = "mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim"
DOCKER_NEW = "mcr.microsoft.com/dotnet/aspnet:10.0-noble"
SKIP_DIRS = {'.git', '.github', 'bin', 'obj', '.idea', '.vs'}
def should_skip(path: Path) -> bool:
return any(part in SKIP_DIRS for part in path.parts)
def update_file(path: Path, old: str, new: str) -> bool:
try:
text = path.read_text(encoding="utf-8")
except UnicodeDecodeError:
return False
if old not in text:
return False
new_text = text.replace(old, new)
if new_text == text:
return False
path.write_text(new_text, encoding="utf-8")
print(f"updated: {path}")
return True
tf_changed = 0
docker_changed = 0
for pattern in ("*.csproj", "*.fsproj", "*.vbproj"):
for path in ROOT.rglob(pattern):
if should_skip(path):
continue
if update_file(path, TF_OLD, TF_NEW):
tf_changed += 1
for path in ROOT.rglob("Dockerfile*"):
if should_skip(path):
continue
if update_file(path, DOCKER_OLD, DOCKER_NEW):
docker_changed += 1
print(f"Summary: project files updated = {tf_changed}, Dockerfiles updated = {docker_changed}")
PY
- name: Set .NET root
run: echo "DOTNET_ROOT=/home/monfex" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '10.0.x'
source-url: https://nuget.pkg.github.com/myjetwallet/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }}
- name: Get current time
uses: MyJetTools/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD HH:mm:ss
utcOffset: "+00:00"
- name: list nugets
run: dotnet nuget list source
working-directory: backend/Service.SimpleWorld
- name: Restore
run: dotnet restore
working-directory: backend/Service.SimpleWorld
continue-on-error: true
- name: Build
run: dotnet build --no-restore --configuration Release /p:AssemblyVersion=${{ inputs.release_version }}
working-directory: backend/Service.SimpleWorld
- name: Test
run: dotnet test --no-build --configuration Release
working-directory: backend/Service.SimpleWorld
# -------------------------
# Publish all 3 services
# -------------------------
- name: Publish Service.SimpleWorld.WalletApi
run: dotnet publish src/Service.SimpleWorld.WalletApi/Service.SimpleWorld.WalletApi.csproj --configuration Release /p:AssemblyVersion=${{ inputs.release_version }} --output ${{ github.workspace }}/publish-walletapi
working-directory: backend/Service.SimpleWorld
- name: Publish Service.SimpleWorld.Worker
run: dotnet publish src/Service.SimpleWorld.Worker/Service.SimpleWorld.Worker.csproj --configuration Release /p:AssemblyVersion=${{ inputs.release_version }} --output ${{ github.workspace }}/publish-worker
working-directory: backend/Service.SimpleWorld
- name: Publish Service.SimpleWorld
run: dotnet publish src/Service.SimpleWorld/Service.SimpleWorld.csproj --configuration Release /p:AssemblyVersion=${{ inputs.release_version }} --output ${{ github.workspace }}/publish-core
working-directory: backend/Service.SimpleWorld
- name: Login to Azure Container Registry
run: |
echo "${{ secrets.ST_DOCKER_PASSWORD }}" | \
docker login ${{ secrets.AZURE_CONTAINER_REGISTRY }} \
-u ${{ secrets.ST_DOCKER_USER }} --password-stdin
# -------------------------
# Build & Push WalletApi
# -------------------------
- name: Build & Push Service.SimpleWorld.WalletApi
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/publish-walletapi
file: backend/Service.SimpleWorld/src/Service.SimpleWorld.WalletApi/Dockerfile
push: true
build-args: |
app_version=myjetwallet.service.simpleworld.walletapi:${{ inputs.release_version }}
app_compilation_date=${{ steps.current-time.outputs.formattedTime }}
tags: ${{ secrets.AZURE_CONTAINER_REGISTRY }}/spot/myjetwallet.service.simpleworld.walletapi:${{ inputs.release_version }}
# -------------------------
# Build & Push Worker
# -------------------------
- name: Build & Push Service.SimpleWorld.Worker
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/publish-worker
file: backend/Service.SimpleWorld/src/Service.SimpleWorld.Worker/Dockerfile
push: true
build-args: |
app_version=myjetwallet.service.simpleworld.worker:${{ inputs.release_version }}
app_compilation_date=${{ steps.current-time.outputs.formattedTime }}
tags: ${{ secrets.AZURE_CONTAINER_REGISTRY }}/spot/myjetwallet.service.simpleworld.worker:${{ inputs.release_version }}
# -------------------------
# Build & Push Core
# -------------------------
- name: Build & Push Service.SimpleWorld
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/publish-core
file: backend/Service.SimpleWorld/src/Service.SimpleWorld/Dockerfile
push: true
build-args: |
app_version=myjetwallet.service.simpleworld:${{ inputs.release_version }}
app_compilation_date=${{ steps.current-time.outputs.formattedTime }}
tags: ${{ secrets.AZURE_CONTAINER_REGISTRY }}/spot/myjetwallet.service.simpleworld:${{ inputs.release_version }}
# =========================================
# K8S DEPLOY — Core + Worker (not WalletApi)
# =========================================
k8s-deploy:
needs: [build]
runs-on: self-hosted
steps:
- name: Checkout kubernates-infrastructure
uses: actions/checkout@v3
with:
repository: MyJetWallet/kubernates-infrastructure
ref: uat
token: ${{ secrets.UAT_GIT_TOKEN }}
- name: Update Service.SimpleWorld image
run: |
pattern=myjetwallet.service.simpleworld:.*$
imagename=myjetwallet.service.simpleworld:${{ inputs.release_version }}
sed -i -r "s/${pattern}/${imagename}/g" $(find . -type f -name "*.*ml")
- name: Update Service.SimpleWorld.Worker image
run: |
pattern=myjetwallet.service.simpleworld.worker:.*$
imagename=myjetwallet.service.simpleworld.worker:${{ inputs.release_version }}
sed -i -r "s/${pattern}/${imagename}/g" $(find . -type f -name "*.*ml")
- name: Commit & Push
run: |
git config user.name github-actions
git config user.email github-actions@github.com
if git status | grep -q modified; then
git commit -a -m "Update SimpleWorld core+worker to ${{ inputs.release_version }}"
git push
fi
# =========================================
# DOCKER DEPLOY — WalletApi → docker-infrastructure
# =========================================
docker-deploy:
needs: [build, k8s-deploy]
runs-on: self-hosted
steps:
- name: Checkout docker-infrastructure
uses: actions/checkout@v3
with:
repository: MyJetWallet/docker-infrastructure
ref: uat
token: ${{ secrets.UAT_GIT_TOKEN }}
- name: Update Service.SimpleWorld.WalletApi image
run: |
pattern=myjetwallet.service.simpleworld.walletapi:.*$
imagename=myjetwallet.service.simpleworld.walletapi:${{ inputs.release_version }}
sed -i -r "s/${pattern}/${imagename}/g" $(find . -type f -name "*.*ml")
- name: Commit & Push
run: |
git config user.name github-actions
git config user.email github-actions@github.com
if git status | grep -q modified; then
git commit -a -m "Update SimpleWorld WalletApi to ${{ inputs.release_version }}"
git push
fi