-
Notifications
You must be signed in to change notification settings - Fork 15
210 lines (185 loc) · 6.71 KB
/
listen-mc-decompile.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
name: listen-mc-decompile
on:
push:
paths:
- 'src/**'
- '.github/**'
- '**.gradle'
workflow_dispatch:
# If you can't post workflow_dispatch event, use this
# schedule:
# - cron: '0/5 * * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Run Gradle
run: |
chmod +x gradlew
./gradlew clean shadowJar -s
- name: Upload Built JAR
uses: actions/upload-artifact@v3
with:
name: built-jar
path: build/libs/gitmc.jar
listen:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out Version Branch
uses: actions/checkout@v3
with:
repository: ${{ secrets.DESTINATION }}
ref: version
ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
path: version
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 17
- name: Download Built JAR
uses: actions/download-artifact@v3
with:
name: built-jar
path: build/libs
- name: Check Minecraft version
run: |
java -cp build/libs/gitmc.jar io.github.nickid2018.gitmc.CheckMinecraft
chmod +x $GITHUB_WORKSPACE/output.sh
$GITHUB_WORKSPACE/output.sh
- name: Upload Remapped JAR
if: env.fail == 'false'
uses: actions/upload-artifact@v3
with:
name: remapped-jar
path: remapped.jar
- name: Check out Write Branch
if: env.fail == 'false'
uses: actions/checkout@v3
with:
repository: ${{ secrets.DESTINATION }}
ref: ${{ env.branch_read }}
ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
path: write
- name: Clean old version files
if: env.fail == 'false'
run: |
cd write
if [ -d "src/main/java" ]; then
rm -rf src/main/java
fi
mkdir -p src/main/java
if [ -d "src/main/resources" ]; then
rm -rf src/main/resources
fi
mkdir -p src/main/resources
cd ..
- name: Decompile Minecraft file (CFR, No Rename)
if: env.fail == 'false' && env.decompiler == 'cfr' && env.rename_var != 'decompiler'
run: java -cp build/libs/gitmc.jar org.benf.cfr.reader.Main --silent true --outputdir write/src/main/java --comments false --aggressivesizethreshold 20000 remapped.jar
- name: Decompile Minecraft file (CFR, Rename)
if: env.fail == 'false' && env.decompiler == 'cfr' && env.rename_var == 'decompiler'
run: java -cp build/libs/gitmc.jar org.benf.cfr.reader.Main --silent true --outputdir write/src/main/java --comments false --aggressivesizethreshold 20000 --usenametable false remapped.jar
- name: Decompile Minecraft file (Fernflower)
if: env.fail == 'false' && env.decompiler == 'fernflower'
run: |
mkdir decompiled
java -cp build/libs/gitmc.jar org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=1 "-ind= " -crp=1 -cps=1 -log=WARN remapped.jar decompiled
unzip -q -o decompiled/remapped.jar '*.java' -d write/src/main/java
- name: Resource files
if: env.fail == 'false'
run: |
unzip -q -o remapped.jar -x '*.class' -d write/src/main/resources
cd write/src/main/resources
for i in `find . -name "*.png" -type f`; do
sha1=`sha1sum $i | awk '{print $1}'`
echo $i $sha1 >> png-list.txt
rm $i
done
sort png-list.txt -o png-list.txt
for i in `find . -name "*.bin" -type f`; do
rm $i
done
for i in `find . -name "*.zip" -type f`; do
rm $i
done
- name: Convert NBT to SNBT
if: env.fail == 'false'
run: |
mkdir tempServer
cd tempServer
wget https://piston-data.mojang.com/v1/objects/8dd1a28015f51b1803213892b50b7b4fc76e594d/server.jar
java -DbundlerMainClass=net.minecraft.data.Main -jar server.jar --dev --input ../write/src/main/resources --output snbt
cp -r snbt/* ../write/src/main/resources
cd ../write/src/main/resources
for i in `find . -name "*.nbt" -type f`; do
rm $i
done
for i in `find . -name "*.snbt" -type f`; do
sed -i '/DataVersion/d' $i
done
- name: Move Build Gradle
if: env.fail == 'false'
run: |
mv gen-build.gradle write/build.gradle
- name: Switch Branch
if: env.branch_read != env.branch_write
run: |
cd write
git checkout -b ${{ env.branch_write }}
cd ..
- name: Commit new version files
if: env.fail == 'false'
run: |
cd write
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m ${{ env.version }} -a
cd ..
- name: Push new version files
if: env.fail == 'false'
uses: ad-m/github-push-action@master
with:
repository: ${{ secrets.DESTINATION }}
ssh: true
branch: ${{ env.branch_write }}
directory: write
- name: Commit version store file
if: env.fail == 'false'
run: |
echo ${{ env.version }} has been decompiled, now update version store json.
cd version
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m ${{ env.version }} -a
cd ..
- name: Push version store file
if: env.fail == 'false'
uses: ad-m/github-push-action@master
with:
repository: ${{ secrets.DESTINATION }}
ssh: true
branch: version
directory: version
- name: Summary Output (Success)
if: env.fail == 'false'
run: |
echo "### Decompile Success" >> $GITHUB_STEP_SUMMARY
echo "Decompile a new Minecraft version **${{ env.version }}**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Branch to write: ${{ env.branch_write }}" >> $GITHUB_STEP_SUMMARY
- name: Summary Output (Fail)
if: env.fail == 'true'
run: |
echo "### Minecraft version (${{ env.version }}) is latest!" >> $GITHUB_STEP_SUMMARY