forked from theonedev/onedev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.onedev-buildspec.yml
280 lines (280 loc) · 11.1 KB
/
.onedev-buildspec.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
version: 25
jobs:
- name: CI
steps:
- !CheckoutStep
name: checkout
cloneCredential: !DefaultCredential {}
withLfs: false
withSubmodules: true
cloneDepth: 1
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: detect build version
runInContainer: true
image: '@property:buildEnvironment@'
interpreter: !DefaultInterpreter
commands:
- set -e
- echo "Detecting project version (may require some time while downloading maven dependencies)..."
- echo $(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout) > buildVersion
useTTY: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetBuildVersionStep
name: set build version
buildVersion: '@file:buildVersion@'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: test
runInContainer: true
image: '@property:buildEnvironment@'
interpreter: !DefaultInterpreter
commands:
- mvn test
useTTY: true
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !BranchUpdateTrigger
branches: main
projects: onedev/server
retryCondition: never
maxRetries: 3
retryDelay: 30
caches:
- key: maven-cache
path: /root/.m2/repository
timeout: 3600
- name: Release
steps:
- !CheckoutStep
name: checkout code
cloneCredential: !HttpCredential
accessTokenSecret: onedev-token
withLfs: false
withSubmodules: true
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: detect build version
runInContainer: true
image: '@property:buildEnvironment@'
interpreter: !DefaultInterpreter
commands:
- set -e
- echo "Detecting project version (may require some time while downloading maven dependencies)..."
- echo $(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout) > buildVersion
useTTY: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetBuildVersionStep
name: set build version
buildVersion: '@file:buildVersion@'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: build and deploy
runInContainer: true
image: '@property:buildEnvironment@'
interpreter: !DefaultInterpreter
commands:
- set -e
- set -o pipefail
- ''
- buildVersion=@build_version@
- ''
- projectDir=`pwd`
- docker login -u robinshen -p @secrets:dockerhub-password@
- ''
- '# Skip test as we''ve already tested in CI build'
- mvn -Dmaven.test.skip=true -Dmaven.deploy.username=@job_token@ -Dmaven.deploy.password=@secrets:maven-deploy-password@ deploy
- ''
- cd $projectDir/server-product/docker
- docker run --privileged --rm tonistiigi/binfmt --install all
- ./build.sh release
- ''
- cd $projectDir/server-product/helm
- ./build.sh
- ''
- cd $projectDir/server-product/target/helm-chart
- cloudsmith push helm onedev/onedev onedev-${buildVersion}.tgz -k @secret:cloudsmith-token@
- ''
- cd $projectDir
- cp server-product/target/onedev-${buildVersion}.zip .
- ''
- mkdir server-plugin-archetype-${buildVersion}
- cd server-plugin/server-plugin-archetype
- mvn help:effective-pom -Doutput=$projectDir/server-plugin-archetype-${buildVersion}/pom.xml
- cd $projectDir
- sed -i 's/\/onedev-build\/workspace\/server-plugin\/server-plugin-archetype\///' server-plugin-archetype-${buildVersion}/pom.xml
- cp -r server-plugin/server-plugin-archetype/src server-plugin-archetype-${buildVersion}
- zip -r server-plugin-archetype-${buildVersion}.zip server-plugin-archetype-${buildVersion}
- tar zcvf server-plugin-archetype-${buildVersion}.tar.gz server-plugin-archetype-${buildVersion}
- ''
- echo "Creating release tag..."
- ''
- git config --global user.name "Robin Shen"
- git config --global user.email "robin@@onedev.io"
- git config --global --add safe.directory /onedev-build/workspace
- ''
- git tag v$buildVersion -m "Release tag"
- git push -f origin v$buildVersion:v$buildVersion
- git config --global --unset http.extraHeader
- git push -f https://robin:@secrets:github-token@@@github.com/theonedev/onedev v$buildVersion:v$buildVersion
- ''
- echo "Creating release in GitHub..."
- ''
- releaseId=$(curl -u robinshine:@secrets:github-token@ https://api.github.com/repos/theonedev/onedev/releases/tags/v$buildVersion | jq '.id')
- ''
- releaseJson="{\"name\":\"$buildVersion\",\"tag_name\":\"v$buildVersion\",\"body\":\"## Installation Guide\n\nhttps://docs.onedev.io/category/installation-guide\n\n## Change Log\n\nhttps://code.onedev.io/onedev/server/~builds/@build_number@/fixed-issues?query=%22State%22+is+%22Released%22+order+by+%22Type%22+asc+and+%22Priority%22+desc\n\n## Incompatibilities\n\nhttps://code.onedev.io/onedev/server/~builds/@build_number@/markdown/Incompatibilities/server-product/system/incompatibilities/incompatibilities.md\"}"
- ''
- 'acceptHeader="Accept: application/vnd.github.v3+json"'
- if [ "$releaseId" == "null" ]; then
- ' curl -u robinshine:@secrets:github-token@ -X POST -H "$acceptHeader" -d "$releaseJson" https://api.github.com/repos/theonedev/onedev/releases'
- else
- ' curl -u robinshine:@secrets:github-token@ -X PATCH -H "$acceptHeader" -d "$releaseJson" https://api.github.com/repos/theonedev/onedev/releases/$releaseId'
- fi
- ''
- unzip onedev-${buildVersion}.zip
- tar zcvf onedev-${buildVersion}.tar.gz onedev-${buildVersion}
- sha256sum onedev-${buildVersion}.zip > onedev-${buildVersion}.zip.sha256
- sha256sum onedev-${buildVersion}.tar.gz > onedev-${buildVersion}.tar.gz.sha256
- sha256sum server-plugin-archetype-${buildVersion}.zip > server-plugin-archetype-${buildVersion}.zip.sha256
- sha256sum server-plugin-archetype-${buildVersion}.tar.gz > server-plugin-archetype-${buildVersion}.tar.gz.sha256
- ''
- cp server-product/target/docker/*.yaml .
useTTY: true
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !PublishArtifactStep
name: publish artifact
artifacts: '*.zip *.tar.gz *.sha256 *.yaml'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !PublishMarkdownReportStep
name: publish markdown report
reportName: Incompatibilities
filePatterns: server-product/system/incompatibilities/**
startPage: server-product/system/incompatibilities/incompatibilities.md
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !BuildImageStep
name: build server docker image
buildPath: server-product/target/docker
dockerfile: server-product/target/docker/Dockerfile.server
tags: 1dev/server 1dev/server:@build_version@
publish: true
removeDanglingImages: true
moreOptions: --builder onedev --platform linux/amd64,linux/arm64
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !BuildImageStep
name: build agent docker image
buildPath: server-product/target/docker
dockerfile: server-product/target/docker/Dockerfile.agent
tags: 1dev/agent
publish: true
removeDanglingImages: true
moreOptions: --builder onedev --platform linux/amd64,linux/arm64
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CloseMilestoneStep
name: close milestone
milestoneName: '@build_version@'
accessTokenSecret: onedev-token
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
jobDependencies:
- jobName: CI
requireSuccessful: true
retryCondition: never
maxRetries: 3
retryDelay: 30
caches:
- key: maven-cache
path: /root/.m2/repository
timeout: 3600
- name: Sync Main (GitHub)
steps:
- !CheckoutStep
name: 'checkout '
cloneCredential: !DefaultCredential {}
withLfs: false
withSubmodules: true
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: sync
runInContainer: true
image: alpine/git:1.0.7
interpreter: !DefaultInterpreter
commands:
- git config --global user.name "Robin Shen"
- git config --global user.email "robin@@onedev.io"
- git config --global --unset http.extraHeader
- git rm -r server-ee
- sed -i '/server-ee/d' pom.xml
- ''
- cat << EOF > license.txt
- MIT License
- ''
- Copyright (c) 2022-2023 onedev.io
- ''
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- 'furnished to do so, subject to the following conditions:'
- ''
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- ''
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- EOF
- ''
- git add pom.xml
- git add license.txt
- git commit -m "Remove EE module"
- git push -f https://robinshine:@secrets:github-token@@@github.com/theonedev/onedev.git HEAD:main
useTTY: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !BranchUpdateTrigger
branches: main
projects: onedev/server
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 3600
- name: Publish Site
steps:
- !CommandStep
name: build
runInContainer: true
image: ubuntu
interpreter: !DefaultInterpreter
commands:
- 'apt update '
- apt install -y zip
- buildVersion=`ls onedev-*.tar.gz | grep -Po 'onedev-\K.*(?=.tar.gz)'`
- tar zxvf onedev-$buildVersion.tar.gz
- mv onedev-$buildVersion onedev-latest
- tar zcvf onedev-latest.tar.gz onedev-latest
- zip -r onedev-latest.zip onedev-latest
- sha256sum onedev-latest.zip > onedev-latest.zip.sha256
- sha256sum onedev-latest.tar.gz > onedev-latest.tar.gz.sha256
- echo $buildVersion > build_version
useTTY: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetBuildVersionStep
name: set version
buildVersion: '@file:build_version@'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !PublishSiteStep
name: publish
artifacts: onedev-latest*
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
jobDependencies:
- jobName: Release
requireSuccessful: true
artifacts: onedev-*.zip onedev-*.tar.gz
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 3600