-
Notifications
You must be signed in to change notification settings - Fork 48
134 lines (117 loc) · 4.34 KB
/
build.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
name: Java CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
force-update:
description: 'Force Flush Velocity Library Cache'
required: false
type: boolean
jobs:
velocity-lib:
runs-on: ubuntu-latest
steps:
- name: Get Velocity Library Cache
if: ${{ ! inputs.force-update }}
uses: actions/cache@v3
with:
path: velocity/libraries
key: ${{ runner.os }}-build-${{ env.cache-name }}}}
- name: Check library cache validity period
if: ${{ ! inputs.force-update }}
id: check-cache
run: |
if [ ! -e velocity/libraries/velocity-api-*.jar ]; then
echo "cache-hit=false" >> $GITHUB_ENV
else
last_modified=$(stat -c %Y velocity/libraries/velocity-api-*.jar)
current_time=$(date +%s)
elapsed_time=$((current_time - last_modified))
if ((elapsed_time > 30 * 24 * 60 * 60)); then
echo "cache-hit=false" >> $GITHUB_ENV
fi
fi
- name: Get Velocity
if: ${{ env.cache-hit == 'false' || inputs.force-update }}
uses: actions/checkout@v3
with:
repository: 'PaperMC/Velocity'
- name: Setup JDK 17
if: ${{ env.cache-hit == 'false' || inputs.force-update }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Build Velocity
if: ${{ env.cache-hit == 'false' || inputs.force-update }}
uses: gradle/gradle-build-action@v2
with:
gradle-version: current
arguments: build
- name: Collection Library
if: ${{ env.cache-hit == 'false' || inputs.force-update }}
run: |
mkdir -p velocity/libraries
cp api/build/libs/velocity-api-*-SNAPSHOT.jar velocity/libraries
cp proxy/build/libs/velocity-proxy-*-SNAPSHOT.jar velocity/libraries
- name: Cache Velocity Library
if: ${{ env.cache-hit == 'false' || inputs.force-update }}
uses: actions/cache@v3
with:
path: velocity/libraries
key: ${{ runner.os }}-build-${{ env.cache-name }}}}
build:
needs: velocity-lib
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Get Velocity Library
uses: actions/cache@v3
with:
path: velocity/libraries
key: ${{ runner.os }}-build-${{ env.cache-name }}}}
- name: Patch Gradle Repositories
run:
sed -ni '/https:\/\/maven.aliyun.com\/repository\/public/{h;n;/https:\/\/repo1.maven.org\/maven2/!{:a;N;/https:\/\/maven.aliyun.com\/repository\/public/!ba;x;H;n};x;H;x};p' repositories
- name: Build Dev
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
uses: gradle/gradle-build-action@v2
with:
gradle-version: current
arguments: ShadowJar
- name: Build Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: gradle/gradle-build-action@v2
with:
gradle-version: current
arguments: ShadowJar -Denv=final
- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Rename Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
mkdir release
mv bukkit/build/libs/MultiLogin-Bukkit-Build_*.jar release/MultiLogin-Bukkit-${{ github.ref_name }}.jar
mv bungee/build/libs/MultiLogin-Bungee-Build_*.jar release/MultiLogin-Bungee-${{ github.ref_name }}.jar
mv velocity/build/libs/MultiLogin-Velocity-Build_*.jar release/MultiLogin-Velocity-${{ github.ref_name }}.jar
- name: Publish Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ github.ref_name }}"
draft: false
prerelease: false
title: "MultiLogin ${{ github.ref_name }}"
files: release/*.jar