forked from TencentBlueKing/bk-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (182 loc) · 6.22 KB
/
release.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
name: Tag Release
on:
push:
tags:
- 'v*'
jobs:
frontend:
name: Build frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install && yarn start && yarn public
working-directory: src/frontend
- uses: actions/upload-artifact@v1
with:
name: frontend
path: src/frontend/frontend/
agent:
name: Build agent on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
fail-fast: true
max-parallel: 3
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.13.15
- uses: actions/checkout@v2
- run: make clean build_linux
working-directory: src/agent/
if: matrix.os == 'ubuntu-latest'
- run: make clean build_macos
working-directory: src/agent/
if: matrix.os == 'macos-latest'
- run: build_windows.bat
shell: cmd
working-directory: src/agent/
if: matrix.os == 'windows-latest'
- uses: actions/upload-artifact@v1
with:
name: agent
path: src/agent/bin/
backend:
name: Build backend and release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: init mysql
run: |
sudo /etc/init.d/mysql start
export MYSQL_PWD=root
for i in *.sql;do echo $i;mysql -h localhost -uroot < $i;done
working-directory: support-files/sql
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Gradle
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle Build Backend Service
working-directory: src/backend/ci
run: ./gradlew clean test build :core:worker:worker-agent:shadowJar -DmavenRepoUrl="https://maven.aliyun.com/nexus/content/groups/public/"
- name: Gradle Build Turbo Service
working-directory: src/backend/turbo
run: |
./gradlew clean copyToRelease -DmavenRepoUrl="https://maven.aliyun.com/nexus/content/groups/public/"
# copy jar to ci release dir
cp -vf release/boot-turbo.jar ${{ github.workspace }}/src/backend/ci/release/
# copy turbo service config template to ci templates dir
cp -vrf support-files/templates/* ${{ github.workspace }}/support-files/templates/
- name: Create artifact - Step1:init
run: |
true # 暂无init需求, 保留此步骤.
- name: Create artifact - Step2:get Agent
uses: actions/download-artifact@v1
with:
name: agent
path: src/agent/bin/
- name: Create artifact - Step3:get Frontend
uses: actions/download-artifact@v1
with:
name: frontend
path: src/frontend/frontend
- name: Create artifact - Step4:make package
id: create-artifact
run: |
version="$(basename $GITHUB_REF)"
echo "::set-output name=version::$version"
ci_ms_wip="sign,monitoring" ci_pkg_dir=/dev/shm/ci ./scripts/packager-ci.sh "$version" bkci-slim.tar.gz
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: bk-ci ${{ github.ref }}
draft: true
prerelease: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bkci-slim.tar.gz
asset_name: bkci-slim.tar.gz
asset_content_type: application/gzip
- name: download codecc
uses: actions/download-artifact@v1
with:
name: codecc
path: ./
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bkcodecc-slim.tar.gz
asset_name: bkcodecc-slim.tar.gz
asset_content_type: application/gzip
codecc:
name: Build CodeCC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: CodeCC Cache Gradle
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-codecc-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-codecc-gradle-
- name: Gradle Build
id: codecc-backend
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 4.6
build-root-directory: src/backend/codecc
arguments: clean copyToRelease -DmavenRepoUrl="https://maven.aliyun.com/nexus/content/groups/public/"
- name: frontend
id: codecc-frontend
run: |
cd src/frontend/devops-codecc
rm -rf dist
npm i
npm run build
if [ -f dist/index.html ]; then
mv dist/index.html dist/frontend#index.html
fi
- name: Create artifact - make package
id: create-artifact
run: |
version="$(basename $GITHUB_REF)"
echo "::set-output name=version::$version"
codecc_pkg_dir=/dev/shm/codecc ./scripts/deploy-codecc/packager-codecc.sh "$version" bkcodecc-slim.tar.gz "$PWD"
- uses: actions/upload-artifact@v1
with:
name: codecc
path: bkcodecc-slim.tar.gz