-
-
Notifications
You must be signed in to change notification settings - Fork 5
186 lines (178 loc) · 8.27 KB
/
maven.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
name: PowerNukkitX
on: [push,pull_request]
jobs:
check-files:
name: Check repository files
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
outputs:
changed-files: ${{ steps.check-changed-files.outputs.all_changed_and_modified_files }}
steps:
- name: Check out repository contents
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for file changes
id: check-changed-files
uses: tj-actions/[email protected]
- name: output list of changed files
run: echo ${{ steps.check-changed-files.outputs.all_changed_and_modified_files }}
build-server:
name: Build PNX server
runs-on: ubuntu-latest
needs: check-files
# event为push且发生改变或push或commit第一条信息+b +u
# event is push and there is a change or push or commit the first message +b +u
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && (contains(needs.check-files.outputs.changed-files, 'src/') || (github.event_name == 'push' && (contains(github.event.commits[0].message, '+b') || contains(github.event.commits[0].message, '+u'))))
steps:
- uses: actions/checkout@v1
with:
submodules: true
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build with Maven
run: mvn -B package -DskipTests=false -Darguments="-Dmaven.javadoc.skip=true"
- name: Get version
id: getVersion
uses: entimaniac/[email protected]
- name: Rename artifacts
run: |
cd target
ls
cd ../
mv target/powernukkitx-${{ steps.getVersion.outputs.version }}-shaded.jar target/powernukkitx-full.jar
mv target/powernukkitx-${{ steps.getVersion.outputs.version }}.jar target/powernukkitx.jar
tar -vczf target/libs.tar.gz target/libs
- name: Calculate hashes
run: |
cd target
mkdir -p hash/sha256 hash/md5
sha256sum powernukkitx-full.jar > hash/sha256/powernukkitx-full.jar.sha256
sha256sum powernukkitx.jar > hash/sha256/powernukkitx.jar.sha256
sha256sum libs.tar.gz > hash/sha256/libs.tar.gz.sha256
md5sum powernukkitx-full.jar > hash/md5/powernukkitx-full.jar.md5
md5sum powernukkitx.jar > hash/md5/powernukkitx.jar.md5
md5sum libs.tar.gz > hash/md5/libs.tar.gz.md5
- name: Archive PNX Core
uses: actions/upload-artifact@v3
if: success()
with:
name: PowerNukkitX-Core
path: target/powernukkitx.jar
- name: Archive PNX Full
uses: actions/upload-artifact@v3
if: success()
with:
name: PowerNukkitX-Full
path: target/powernukkitx-full.jar
- name: Archive Libraries
uses: actions/upload-artifact@v3
if: success()
with:
name: PowerNukkitX-Libs
path: target/libs/
- name: Archive Hashes
uses: actions/upload-artifact@v3
if: success()
with:
name: Hashes(md5 & sha256)
path: target/hash/
- name: Get Short SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- uses: ncipollo/release-action@v1
name: Release new version
if: success() && contains(github.event.commits[0].message, '+u') && github.repository == 'PowerNukkitX/PowerNukkitX' && contains(github.ref_name, 'master')
with:
artifacts: "target/powernukkitx.jar,target/libs.tar.gz,target/hash/sha256/powernukkitx.jar.sha256,target/hash/sha256/libs.tar.gz.sha256,target/hash/md5/powernukkitx.jar.md5,target/hash/md5/libs.tar.gz.md5"
tag: ${{ steps.getVersion.outputs.version }}
body: ${{ steps.getVersion.outputs.version }} - ${{ github.ref_name }} - ${{ steps.vars.outputs.sha_short }}
token: ${{ secrets.GITHUB_TOKEN }}
commit: ${{ github.ref_name }}
allowUpdates: true
- name: Upload to OSS
uses: tvrcgo/[email protected]
if: github.event_name == 'push' && github.repository == 'PowerNukkitX/PowerNukkitX' && (!contains(github.ref_name, 'patch')) && (!contains(github.ref_name, 'feature'))
with:
key-id: ${{ secrets.OSS_KEY_ID }}
key-secret: ${{ secrets.OSS_KEY_SECRET }}
region: oss-cn-hongkong
bucket: pnx-assets
asset-path: ./target/powernukkitx.jar
target-path: /core/${{ github.ref_name }}-${{ steps.vars.outputs.sha_short }}/
- name: Get Time
id: time
uses: nanzm/[email protected]
if: github.repository == 'PowerNukkitX/PowerNukkitX' && (!contains(github.ref_name, 'patch')) && (!contains(github.ref_name, 'feature'))
with:
timeZone: 8
format: 'YYYY/MM/DD-HH:mm:ss'
- name: Format ChangeLog
uses: mkungla/actions-set-text-output@v1
id: get-changelog
if: success() && github.event_name == 'push' && github.repository == 'PowerNukkitX/PowerNukkitX' && (!contains(github.ref_name, 'patch')) && (!contains(github.ref_name, 'feature'))
with:
text: ${{ github.event.commits[0].message }}
- name: Update MineBBS infomation
uses: fjogeleit/http-request-action@v1
if: success() && github.event_name == 'push' && github.repository == 'PowerNukkitX/PowerNukkitX' && (!contains(github.ref_name, 'patch')) && (!contains(github.ref_name, 'feature'))
with:
url: 'https://api.minebbs.com/api/openapi/v1/resources/3668/update'
method: 'POST'
customHeaders: '{"Authorization": "Bearer ${{ secrets.MINEBBS_API_KEY }}"}'
contentType: 'application/json'
data: '{"title": "${{ github.ref_name }}-${{ steps.vars.outputs.sha_short }}", "description": "${{ steps.get-changelog.outputs.value }}", "new_version": "${{ steps.time.outputs.time }}", "file_url": "https://ci.lt-name.cn/job/PowerNukkitX/"}'
escapeData: 'true'
preventFailureOnNoResponse: 'true'
ignoreStatusCodes: '400,404,401,403,500,502,503,504'
# build-bootstrap:
# name: 构建启动器
# runs-on: ubuntu-latest
# needs: check-files
# if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && (contains(needs.check-files.outputs.changed-files, 'Bootstrap/src/') || (github.event_name == 'push' && contains(github.event.commits[0].message, '+b')))
#
# steps:
# - uses: actions/checkout@v1
# with:
# submodules: true
# - uses: actions/cache@v1
# with:
# path: ~/.m2/repository
# key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
# restore-keys: |
# ${{ runner.os }}-maven-
# - name: Set up JDK 17
# uses: actions/setup-java@v1
# with:
# java-version: 17
# - name: Build with Maven
# run: mvn -B -f Bootstrap/pom.xml package -DskipTests=false -Darguments="-Dmaven.javadoc.skip=true"
# - name: Rename artifacts
# run: mv Bootstrap/target/Bootstrap-*-shaded.jar Bootstrap/target/bootstrap.jar
# - name: Archive artifacts
# uses: actions/upload-artifact@v3
# if: success()
# with:
# name: PowerNukkitX-bootstrap
# path: Bootstrap/target/bootstrap.jar
# - name: Get Short SHA
# id: vars
# run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# - name: Upload to OSS
# uses: tvrcgo/[email protected]
# if: github.event_name == 'push' && github.repository == 'PowerNukkitX/PowerNukkitX' && (!contains(github.ref_name, 'patch')) && (!contains(github.ref_name, 'feature'))
# with:
# key-id: ${{ secrets.OSS_KEY_ID }}
# key-secret: ${{ secrets.OSS_KEY_SECRET }}
# region: oss-cn-hongkong
# bucket: pnx-assets
# asset-path: ./Bootstrap/target/bootstrap.jar
# target-path: /bootstrap/${{ github.ref_name }}-${{ steps.vars.outputs.sha_short }}/