-
Notifications
You must be signed in to change notification settings - Fork 6
214 lines (178 loc) · 7.26 KB
/
folia.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
# This is a basic workflow to help you get started with Actions
name: folia
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: "0 16 * * *"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-default-branch:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: set the git information
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: set-timezone
run: |
sudo timedatectl set-timezone Asia/Shanghai
# Runs a set of commands using the runners shell
- name: clone folia repo
run: |
git clone https://github.com/PaperMC/Folia.git ~/folia
- name: get build java version
id: get_build_java_ver1
run: |
echo "::set-output name=get_build_java_ver1::$(cat ~/folia/.github/workflows/build.yml | grep java-version | sed 's/^.........................//'| sed 's/^.................//' | sed 's/.$//')"
- uses: actions/checkout@v4
- name: JDK 21
uses: actions/setup-java@v4
with:
java-version: ${{ steps.get_build_java_ver1.outputs.get_build_java_ver1 }}
distribution: 'zulu'
- name: Get dev branch info
id: dev
run: |
cd ~/folia
echo "::set-output name=dev::$(git branch -a | grep dev | sed 's/^.................//' | sort -rV )"
- name: applyPathches
run: |
cd ~/folia
./gradlew applyPatches
- name: building...
run: |
cd ~/folia
./gradlew createMojmapPaperclipJar
# Get the date of the build
- name: Get date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: get jar file name
id: get_name
run: echo "::set-output name=name::$(ls ~/folia/build/libs/ | grep paperclip)"
- name: get latest commit information
id: get_commit_info
run: |
cd ~/folia
echo "::set-output name=commit_info1::$(echo default banch:)"
echo "::set-output name=commit_info2::$(echo [$(git rev-parse --short HEAD)]"(https://github.com/papermc/folia/commit/$(git rev-parse HEAD))": $(git log -1 --pretty=format:"%s" ))"
echo "::set-output name=commit_info3::$(echo dev banch:)"
echo "::set-output name=commit_info4::$(echo [$(git rev-parse --short origin/${{ steps.dev.outputs.dev }})]"(https://github.com/papermc/folia/commit/$(git rev-parse origin/${{ steps.dev.outputs.dev }}))": $(git log -1 --pretty=format:"%s"))"
# Create a release with the date as the title and tag
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.date.outputs.date }}
release_name: ${{ steps.date.outputs.date }}
body: |
${{ steps.get_commit_info.outputs.commit_info1 }}
${{ steps.get_commit_info.outputs.commit_info2 }}
${{ steps.get_commit_info.outputs.commit_info3 }}
${{ steps.get_commit_info.outputs.commit_info4 }}
draft: false
prerelease: false
# Upload the jar file to the release as an asset
- name: Upload Release Asset
id: 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: /home/runner/folia/build/libs/${{ steps.get_name.outputs.name }}
asset_name: ${{ steps.get_name.outputs.name }}
asset_content_type: application/java-archive
- name: set upload_url
id: set_upload_url
uses: noobly314/share-data@v1
with:
share-id: release_url
mode: set
key: url
value: ${{ steps.create_release.outputs.upload_url }}
permissions:
contents: write
build-dev-branch:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: build-default-branch
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: set the git information
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: set-timezone
run: |
sudo timedatectl set-timezone Asia/Shanghai
# Runs a set of commands using the runners shell
- name: clone folia repo
run: |
git clone https://github.com/PaperMC/Folia.git ~/folia
- name: Get dev branch info
id: dev1
run: |
cd ~/folia
echo "::set-output name=dev1::$(git branch -a | grep dev | sed 's/^.................//' | sort -rV )"
- name: checkout dev branch
run: |
cd ~/folia
git checkout ${{ steps.dev1.outputs.dev1 }}
- name: get build java version
id: get_build_java_ver2
run: |
echo "::set-output name=get_build_java_ver2::$(cat ~/folia/.github/workflows/build.yml | grep java-version | sed 's/^.........................//'| sed 's/^.................//' | sed 's/.$//')"
- uses: actions/checkout@v4
- name: JDK 21
uses: actions/setup-java@v4
with:
java-version: ${{ steps.get_build_java_ver2.outputs.get_build_java_ver2 }}
distribution: 'zulu'
- name: applyPathches
run: |
cd ~/folia
./gradlew applyPatches
- name: building...
run: |
cd ~/folia
./gradlew createMojmapPaperclipJar
# Get the date of the build
- name: Get date
id: date1
run: echo "::set-output name=date1::$(date +'%Y-%m-%d')"
- name: get jar file name
id: get_name1
run: echo "::set-output name=name1::$(ls ~/folia/build/libs/ | grep paperclip)"
- name: get upload_url
id: get_upload_url
uses: noobly314/share-data@v1
with:
share-id: release_url
mode: get
key: url
# Upload the jar file to the release as an asset
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_upload_url.outputs.data }}
asset_path: /home/runner/folia/build/libs/${{ steps.get_name1.outputs.name1 }}
asset_name: ${{ steps.get_name1.outputs.name1 }}
asset_content_type: application/java-archive
permissions:
contents: write