-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (159 loc) · 7.1 KB
/
launcher.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
name: Launcher
run-name: Auto Update Version
on:
schedule:
- cron: 0 16 * * *
workflow_dispatch:
jobs:
update:
name: Update Launcher
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- subtitle: HMCL
url: https://github.com/HMCL-dev/HMCL
- subtitle: HMCL-PE
url: https://github.com/HMCL-dev/HMCL-PE
- subtitle: PCL2
url: https://github.com/Hex-Dragon/PCL2
- subtitle: FCL
url: https://github.com/FCL-Team/FoldCraftLauncher
- subtitle: PojavLauncher
url: https://github.com/PojavLauncherTeam/PojavLauncher
device: Android
- subtitle: PojavLauncher
url: https://github.com/PojavLauncherTeam/PojavLauncher_iOS
device: iOS
- subtitle: ColorMC
url: https://github.com/Coloryr/ColorMC
device: Windows|macOS|Linux
- subtitle: ColorMC
url: https://github.com/Coloryr/ColorMC.Android
device: Android
- subtitle: XMCL
url: https://github.com/Voxelum/x-minecraft-launcher
- subtitle: Prism
url: https://github.com/PrismLauncher/PrismLauncher
steps:
- uses: actions/checkout@main
- name: Handle files
id: handle
run: |
API=`echo ${{ matrix.url }} | sed 's/:\/\/github\.com\//:\/\/api.github.com\/repos\//g' | sed 's/$/\/releases/g'`
wget -O latest.json $API/latest || echo '{"tag_name":""}' > latest.json
wget -O releases.json $API
if [ '${{ matrix.device }}' ]; then
DEVICE_LIST=`echo '${{ matrix.device }}' | sed 's/|/\\\\|/g'`
sed -n '/\('"$DEVICE_LIST"'\)Launcher/,/]/p' data/launcher.js > launcher.js
else
cp data/launcher.js launcher.js
fi
- name: Get ${{ matrix.subtitle }} version
id: get
run: |
# Get Last Stable ${{ matrix.subtitle }}
LAST_STABLE_VERSION=`sed -n '/"${{ matrix.subtitle }}"/,/version:/p' launcher.js | sed -n '$p' | sed 's/^.*:\s*"v\?\|",$//gi' | sed 's/\./\\\\./g'`
# Get Last Dev ${{ matrix.subtitle }}
LAST_DEV_VERSION=`sed -n '/"${{ matrix.subtitle }}"/,/}/p' launcher.js | sed -n '/dev:/,/version:/p' | sed -n '$p' | sed 's/^.*:\s*"v\?\|"$//gi' | sed 's/\./\\\\./g'`
# GET Latest Stable ${{ matrix.subtitle }}
if [ '${{ matrix.subtitle }}' = HMCL ]; then
LATEST_STABLE_VERSION=`cat releases.json | sed -n '/"tag_name":\s*"release-/p' | sed -n 1p | sed 's/^.*release-\|",$//g' | sed 's/\./\\\\./g'`
else
LATEST_STABLE_VERSION=`cat latest.json | jq .tag_name | sed 's/^"v\?\|"$//gi' | sed 's/\./\\\\./g'`
fi
if [ ${#LATEST_STABLE_VERSION} = 0 ]; then
unset LAST_STABLE_VERSION
fi
# GET Latest Dev ${{ matrix.subtitle }}
if [ "$LAST_DEV_VERSION" ]; then
LATEST_DEV_VERSION=`cat releases.json | sed -n '/"tag_name":/p' | sed -n 1p | sed 's/^.*:\s*"v\?\|",$//gi' | sed 's/\./\\\\./g'`
if [ "$LATEST_DEV_VERSION" = "$LATEST_STABLE_VERSION" ]; then
unset LATEST_DEV_VERSION
fi
fi
# Remove Needless Files
rm latest.json releases.json launcher.js
# Output
echo "last_stable_version=$LAST_STABLE_VERSION" >> $GITHUB_OUTPUT
echo "last_dev_version=$LAST_DEV_VERSION" >> $GITHUB_OUTPUT
echo "latest_stable_version=$LATEST_STABLE_VERSION" >> $GITHUB_OUTPUT
echo "latest_dev_version=$LATEST_DEV_VERSION" >> $GITHUB_OUTPUT
- name: Modify launcher.js
id: modify
run: |
LAST_STABLE_VERSION='${{ steps.get.outputs.last_stable_version }}'
LAST_DEV_VERSION='${{ steps.get.outputs.last_dev_version }}'
LATEST_STABLE_VERSION='${{ steps.get.outputs.latest_stable_version }}'
LATEST_DEV_VERSION='${{ steps.get.outputs.latest_dev_version }}'
if [ '${{ matrix.device }}' ]; then
DEVICE_STRING=' [${{ matrix.device }}]'
else
DEVICE_STRING=''
fi
if [ "$LATEST_STABLE_VERSION" ]; then
if [ "$LAST_STABLE_VERSION" != "$LATEST_STABLE_VERSION" ]; then
sed -i 's/\([/"v-]\)'"$LAST_STABLE_VERSION"'\(\.[a-z]\|["/-]\)/\1'"$LATEST_STABLE_VERSION"'\2/gi' data/launcher.js
LAST_STABLE_VERSION=`echo $LAST_STABLE_VERSION | sed 's/\\\\././g'`
LATEST_STABLE_VERSION=`echo $LATEST_STABLE_VERSION | sed 's/\\\\././g'`
CHANGELOG_E=' ${{ matrix.subtitle }}(stable): '"$LAST_STABLE_VERSION => $LATEST_STABLE_VERSION$DEVICE_STRING"
fi
fi
if [ "$LATEST_DEV_VERSION" ]; then
if [ "$LAST_DEV_VERSION" != "$LATEST_DEV_VERSION" ]; then
sed -i 's/\([/"v-]\)'"$LAST_DEV_VERSION"'\(\.[a-z]\|["/-]\)/\1'"$LATEST_DEV_VERSION"'\2/gi' data/launcher.js
LAST_DEV_VERSION=`echo $LAST_DEV_VERSION | sed 's/\\\\././g'`
LATEST_DEV_VERSION=`echo $LATEST_DEV_VERSION | sed 's/\\\\././g'`
if [ "$CHANGELOG_E" ]; then
CHANGELOG_E="${CHANGELOG_E}"'#n ${{ matrix.subtitle }}(dev): '"$LAST_DEV_VERSION => $LATEST_DEV_VERSION$DEVICE_STRING"
else
CHANGELOG_E=' ${{ matrix.subtitle }}(dev): '"$LAST_DEV_VERSION => $LATEST_DEV_VERSION$DEVICE_STRING"
fi
fi
fi
if [ "$CHANGELOG_E" ]; then
CHANGELOG=`echo "$CHANGELOG_E" | sed 's/#n/\n/g'`
echo ===============================================================
echo "$CHANGELOG"
echo ===============================================================
echo "changelog=$CHANGELOG_E" >> $GITHUB_OUTPUT
fi
- name: Commit changes
id: commit
continue-on-error: true
run: |
git config --global user.name teaSummer
git config --global user.email see_tea@outlook.com
CHANGELOG=`echo '${{ steps.modify.outputs.changelog }}' | sed 's/#n/\n/g'`
git commit -am 'modified: update ${{ matrix.subtitle }}
[Auto] Update Launcher Version:
'"$CHANGELOG
(Time: `date +'%F %X %Z'`)"
git pull --rebase
- name: Push changes
if: ${{ steps.commit.outcome == 'success' }}
id: push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN }}
branch: main
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: update
steps:
- name: Run remote commands
id: run
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.HOST }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
command: |
echo ===============================================================
cd /www/wwwroot/mcisee.top
git pull
echo ===============================================================