-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (157 loc) · 5.97 KB
/
Copy pathbuild-deploy-bundle.yml
File metadata and controls
176 lines (157 loc) · 5.97 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
name: Build Deploy Bundle
on:
push:
branches:
- main
- master
tags-ignore:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
package:
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
cache: gradle
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Run deploy packaging script
shell: cmd
run: deploy-server.bat
- name: Compress deploy-bundle folder
shell: powershell
run: |
if (Test-Path "deploy-bundle.zip") { Remove-Item "deploy-bundle.zip" -Force }
Compress-Archive -Path "deploy-bundle\*" -DestinationPath "deploy-bundle.zip" -Force
if (Test-Path "frontend-dist.zip") { Remove-Item "frontend-dist.zip" -Force }
Compress-Archive -Path "deploy-bundle\frontend\dist\*" -DestinationPath "frontend-dist.zip" -Force
if (Test-Path "deploy-bundle\docs\*") {
if (Test-Path "docs-dist.zip") { Remove-Item "docs-dist.zip" -Force }
Compress-Archive -Path "deploy-bundle\docs\*" -DestinationPath "docs-dist.zip" -Force
}
- name: Upload deploy bundle zip
uses: actions/upload-artifact@v4
with:
name: deploy-bundle-zip
path: deploy-bundle.zip
if-no-files-found: error
retention-days: 14
- name: Upload backend jar
uses: actions/upload-artifact@v4
with:
name: backend-app-jar
path: deploy-bundle/app/app.jar
if-no-files-found: error
retention-days: 14
- name: Upload frontend dist
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: deploy-bundle/frontend/dist
if-no-files-found: error
retention-days: 14
- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: docs-dist
path: deploy-bundle/docs
if-no-files-found: warn
retention-days: 14
- name: Upload plugins
uses: actions/upload-artifact@v4
with:
name: crypto-plugins
path: deploy-bundle/plugins/
if-no-files-found: warn
retention-days: 14
- name: Compute next version and release notes
id: versioning
shell: powershell
run: |
git fetch --tags --force
$semverPattern = '^v\d+\.\d+\.\d+$'
$headTag = git tag --points-at HEAD | Where-Object { $_ -match $semverPattern } | Select-Object -First 1
if ($headTag) {
$newTag = $headTag.Trim()
$lastTag = git tag --list "v*" --sort=-v:refname | Where-Object { $_ -match $semverPattern } | Select-Object -First 2 | Select-Object -Last 1
} else {
$lastTag = git tag --list "v*" --sort=-v:refname | Where-Object { $_ -match $semverPattern } | Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($lastTag)) {
$newTag = "v1.0.0"
} else {
$parts = $lastTag.TrimStart('v').Split('.')
$major = [int]$parts[0]
$minor = [int]$parts[1]
$patch = [int]$parts[2] + 1
$newTag = "v$major.$minor.$patch"
}
}
if ([string]::IsNullOrWhiteSpace($lastTag)) {
$logRange = "HEAD"
} else {
$logRange = "$lastTag..HEAD"
}
$rawCommits = git log $logRange --max-count=4 --pretty=format:"%h|%s"
if ([string]::IsNullOrWhiteSpace($rawCommits)) {
$messages = "- No code changes detected (possibly a rebuild run)."
} else {
$lines = @()
foreach ($row in ($rawCommits -split "`r?`n")) {
if ([string]::IsNullOrWhiteSpace($row)) { continue }
$parts = $row.Split("|", 2)
$sha = $parts[0]
$subject = if ($parts.Count -gt 1) { $parts[1] } else { "(no subject)" }
$lines += "- $subject"
$lines += " - commit: $sha"
}
$messages = $lines -join "`n"
}
Add-Content -Path $env:GITHUB_OUTPUT -Value "tag=$newTag"
Add-Content -Path $env:GITHUB_OUTPUT -Value "last_tag=$lastTag"
$releaseBodyFile = Join-Path $env:RUNNER_TEMP "release-body.md"
$templatePath = ".github/release-template.md"
if (!(Test-Path $templatePath)) {
throw "Missing release template file: $templatePath"
}
$template = [System.IO.File]::ReadAllText($templatePath, [System.Text.Encoding]::UTF8)
$releaseBody = $template.Replace("{{CHANGELOG}}", $messages)
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($releaseBodyFile, $releaseBody, $utf8NoBom)
Add-Content -Path $env:GITHUB_OUTPUT -Value "release_body_file=$releaseBodyFile"
- name: Create git tag (if missing)
shell: powershell
run: |
$tag = "${{ steps.versioning.outputs.tag }}"
git fetch --tags --force
$exists = git tag --list $tag
if ([string]::IsNullOrWhiteSpace($exists)) {
git tag $tag
git push origin $tag
} else {
Write-Host "Tag $tag already exists, skip creating."
}
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.versioning.outputs.tag }}
name: ${{ steps.versioning.outputs.tag }}
body_path: ${{ steps.versioning.outputs.release_body_file }}
files: |
deploy-bundle.zip
deploy-bundle/app/app.jar
deploy-bundle/plugins/*.jar
frontend-dist.zip
docs-dist.zip