forked from eclipse-aaspe/server
-
Notifications
You must be signed in to change notification settings - Fork 0
358 lines (321 loc) · 12.9 KB
/
prerelease-on-merge-to-main.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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: Nightly Prerelease build on Main
on:
schedule:
- cron: '0 23 * * 1-5' # This is 1:00 AM Berlin time from Monday to Friday
workflow_dispatch: # Allows manual triggering
env:
BRANCH_SUFFIX: latest
VERSION_SUFFIX: alpha
jobs:
check-for-changes:
runs-on: windows-latest
name: Check for changes between HEAD and last created tag
if: github.event_name != 'schedule' || github.repository == 'eclipse-aaspe/server'
outputs:
branch_changed: ${{ steps.check_changes.outputs.changes_detected }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check changes since last tag
id: check_changes
run: |
git fetch --tags
$tags = git tag --sort=-creatordate
Write-Host "Tags: $tags"
$branchSuffix = "${{ env.BRANCH_SUFFIX }}"
$potentialTags = @()
foreach ($tag in $tags)
{
if ($tag -match ".*-$branchSuffix$")
{
$potentialTags += $tag
}
}
if ($potentialTags.Count -gt 0)
{
$latestTag = $potentialTags[0]
Write-Host "Latest found matching tag is $latestTag"
}
else
{
Write-Host "No matching tags found, fetching the latest tag."
$latestTag = $tags | Select-Object -First 1
if ($latestTag)
{
echo "from_tag=$latestTag" >> $env:GITHUB_OUTPUT
Write-Host "Latest found tag is $latestTag"
}
else
{
Write-Host "No tags found at all."
exit 1
}
}
Write-Host "Checking changes since tag: $latestTag"
$range = "$latestTag..@"
Write-Host "Check for changes in range: $range"
$changes = git log $range --oneline
Write-Host "Found changes: $changes"
if (-not [string]::IsNullOrEmpty($changes))
{
Write-Host "Changes detected since $latestTag"
Write-Host "$changes"
echo "changes_detected=true" >> $env:GITHUB_OUTPUT
}
else
{
Write-Host "No changes detected since $latestTag."
echo "changes_detected=false" >> $env:GITHUB_OUTPUT
}
shell: pwsh
create-new-prerelease:
runs-on: windows-latest
name: Create a new prerelease build and attach built packages to release
needs: check-for-changes
permissions:
contents: write
pull-requests: write
if: needs.check-for-changes.outputs.branch_changed == 'true'
outputs:
VERSION_NUMBER: ${{ steps.generate_version_number.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set execution policy
run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
shell: pwsh
- name: Extract branch name
id: extract_branch
run: |
$branch = '${{ github.ref }}' -replace 'refs/heads/', ''
echo "branch=$branch" >> $env:GITHUB_OUTPUT
Write-Host "The current branch is: $branch"
shell: pwsh
- name: Get the newest tag
id: get_latest_tag
run: |
git fetch --tags
$tags = git tag --sort=-creatordate
$branchSuffix = "${{ env.BRANCH_SUFFIX }}"
$potentialTags = @()
foreach ($tag in $tags) {
if ($tag -match ".*-$branchSuffix$") {
$potentialTags += $tag
}
}
if ($potentialTags.Count -gt 0) {
$newestStableTag = $potentialTags[0]
echo "from_tag=$newestStableTag" >> $env:GITHUB_OUTPUT
Write-Host "Latest found tag is $newestStableTag"
} else {
Write-Host "No matching tags found, fetching the latest tag."
$latestTag = $tags | Select-Object -First 1
if ($latestTag) {
echo "from_tag=$latestTag" >> $env:GITHUB_OUTPUT
Write-Host "Latest found tag is $latestTag"
} else {
Write-Host "No tags found at all."
exit 1
}
}
shell: pwsh
- name: Generate Version Number
working-directory: src
id: generate_version_number
run: |
$branch = '${{ steps.extract_branch.outputs.branch }}'
$version = .\BuildVersionNumber.ps1 -suffix $VERSION_SUFFIX -branch $branch -githubRunNumber ${{ github.run_number }}
echo "version=$version" >> $env:GITHUB_OUTPUT
Write-Host "The version name to build is: $version"
shell: pwsh
- name: Update version numbers in project
working-directory: src
run: |
$version = '${{ steps.generate_version_number.outputs.version }}'
Write-Host "Updating project versions to: $version"
.\UpdateProjectVersions.ps1 -version $version
shell: pwsh
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Build release
working-directory: src
run: .\BuildForRelease.ps1
shell: pwsh
- name: Package release
working-directory: src
run: |
$version = 'v${{ steps.generate_version_number.outputs.version }}'
mkdir -p artefacts/release/$version
Write-Host "Packaging for the release version: $version"
.\PackageRelease.ps1 -version $version
shell: pwsh
- name: Rename the release assets
working-directory: .
run: |
$version = 'v${{ steps.generate_version_number.outputs.version }}'
$releaseDir = Join-Path $(Get-Location) "artefacts/release/$version"
Write-Host "Release directory: $releaseDir"
if (!(Test-Path $releaseDir)) {
throw "The release directory does not exist: $releaseDir"
}
$archives = Get-ChildItem $releaseDir -Filter *.zip
foreach($archive in $archives) {
$path = $archive.FullName
Write-Host "The path to the archive is: $path"
$nameWoExt = [io.path]::GetFileNameWithoutExtension($path)
Write-Host "The name without extension is: $nameWoExt"
$target = Join-Path $releaseDir ($nameWoExt + "." + $version + ".zip")
Write-Host "Moving: $path -> $target"
Move-Item -Path $path -Destination $target
}
shell: pwsh
- name: Create Git tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag v${{ steps.generate_version_number.outputs.version }}
git push origin v${{ steps.generate_version_number.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate release notes
id: generate_release_notes
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/changelog_configuration.json"
token: ${{ secrets.GITHUB_TOKEN }}
fromTag: "${{ steps.get_latest_tag.outputs.from_tag }}"
toTag: "v${{ steps.generate_version_number.outputs.version }}"
fetchViaCommits: "true"
ignorePreReleases: "false"
fetchReleaseInformation: "true"
failOnError: "true"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ steps.generate_version_number.outputs.version }}"
name: "v${{ steps.generate_version_number.outputs.version }}"
draft: false
prerelease: true
body: ${{ steps.generate_release_notes.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload the release assets
uses: AButler/[email protected]
with:
files: "artefacts/release/v${{ steps.generate_version_number.outputs.version }}/*.zip"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: "v${{ steps.generate_version_number.outputs.version }}"
build-and-publish-docker-release-images:
runs-on: ubuntu-latest
name: Create new docker builds with latest prerelease and upload to DockerHub
needs: create-new-prerelease
if: github.repository == 'eclipse-aaspe/server'
steps:
- name: Checkout
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
with:
platforms: linux/amd64,linux/arm64,linux/arm32
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: adminshellio
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set version number
id: set-version
run: echo "VERSION_NUMBER=$(echo ${{ needs.create-new-prerelease.outputs.VERSION_NUMBER }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Determine Docker tag
id: set-docker-tag
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "tag=main" >> $GITHUB_OUTPUT
else
echo "tag=develop" >> $GITHUB_OUTPUT
fi
- name: Build and publish multi-architecture Docker image for AASX Server Blazor
uses: docker/build-push-action@v6
with:
push: true
file: ./src/docker/Dockerfile-AasxServerBlazor
platforms: |
linux/amd64
linux/arm/v6
linux/arm/v7
linux/arm64
tags: |
adminshellio/aasx-server-blazor-for-demo:${{ steps.set-docker-tag.outputs.tag }}
adminshellio/aasx-server-blazor-for-demo:${{ env.VERSION_NUMBER }}
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: "version=${{ env.VERSION_NUMBER }}"
- name: Build and publish multi-architecture Docker image for AasxServerCore
uses: docker/build-push-action@v6
with:
push: true
file: ./src/docker/Dockerfile-AasxServerAspNetCore
platforms: |
linux/amd64
linux/arm/v6
linux/arm/v7
linux/arm64
tags: |
adminshellio/aasx-server-aspnetcore-for-demo:${{ steps.set-docker-tag.outputs.tag }}
adminshellio/aasx-server-aspnetcore-for-demo:${{ env.VERSION_NUMBER }}
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: "version=${{ env.VERSION_NUMBER }}"
# --------------------------------------------------------------------------------------------------
# These are the old specific docker image builds. We need to decide, if we want to delete them
# and only use the multi-platform builds
# --------------------------------------------------------------------------------------------------
- name: Build and publish AasxServerBlazor-arm32
uses: docker/build-push-action@v6
with:
push: true
load: true
file: ./src/docker/Dockerfile-AasxServerBlazor
platforms: linux/arm/v7
tags: adminshellio/aasx-server-blazor-for-demo-arm32:${{ steps.set-docker-tag.outputs.tag }}
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: "version =${{ env.VERSION_NUMBER }}"
- name: Build and publish AasxServerBlazor-arm64
uses: docker/build-push-action@v6
with:
push: true
load: true
file: ./src/docker/Dockerfile-AasxServerBlazor
platforms: linux/arm64
tags: adminshellio/aasx-server-blazor-for-demo-arm64:${{ steps.set-docker-tag.outputs.tag }}
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: "version =${{ env.VERSION_NUMBER }}"
- name: Build and publish AasxServerCore-arm32
uses: docker/build-push-action@v6
with:
push: true
load: true
file: ./src/docker/Dockerfile-AasxServerAspNetCore
platforms: linux/arm/v7
tags: adminshellio/aasx-server-aspnetcore-for-demo-arm32:${{ steps.set-docker-tag.outputs.tag }}
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: "version =${{ env.VERSION_NUMBER }}"
- name: Build and publish AasxServerCore-arm64
uses: docker/build-push-action@v6
with:
push: true
load: true
file: ./src/docker/Dockerfile-AasxServerAspNetCore
platforms: linux/arm64
tags: adminshellio/aasx-server-aspnetcore-for-demo-arm64:${{ steps.set-docker-tag.outputs.tag }}
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: "version =${{ env.VERSION_NUMBER }}"