-
-
Notifications
You must be signed in to change notification settings - Fork 0
363 lines (356 loc) · 17.9 KB
/
artifacts.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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: "Artifacts"
on:
push:
branches: [ master ]
schedule:
- cron: '0 */12 * * *'
permissions: write-all
jobs:
artifacts:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Artifacts
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
git fetch --depth 1 origin +refs/tags/artifacts:refs/tags/artifacts --no-tags
bash --noprofile --norc -e -o pipefail docs/tools/actions-artifacts.sh
export GIT_AUTHOR_DATE="$(git log -1 --format=%aD)"
export GIT_COMMITTER_DATE="$(git log -1 --format=%cD)"
git -c user.name="GitHub" -c user.email="[email protected]" commit --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" -m"Add vendored Node modules
Node modules and their dependencies updated to the latest versions found in https://github.com/${{ github.repository }}/blob/master/package.json" | sed -n 1p
git checkout -- '.gitignore'
if [[ $(git status --porcelain | tee /dev/stderr | head -c1 | wc -c) -ne 0 || $(git clean -dffx | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
# Artifacts
git tag -f artifacts
git push -f origin refs/tags/artifacts:refs/tags/artifacts
readme:
runs-on: ubuntu-latest
needs: artifacts
if: needs.artifacts.result == 'success'
steps:
- uses: actions/[email protected]
- name: README
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
git fetch --depth 1 origin +refs/tags/artifacts:refs/tags/artifacts --no-tags
git restore --source=artifacts -- bin/ node_modules/ package-lock.json
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
bin/linux/x64/node/node-v$node_version-linux-x64/bin/node --use_strict index.js --readme_only
rm -r bin/
rm -r node_modules/
rm package-lock.json
git checkout -- downloadlist.json
git add README.html README.md
git -c user.name="GitHub" -c user.email="[email protected]" commit --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" -m"Update README" | sed -n 1p || true
if [[ $(git status --porcelain | tee /dev/stderr | head -c1 | wc -c) -ne 0 || $(git clean -dffx | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
- id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update README
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <[email protected]>
title: Update README
body: |
Update the README to reflect the latest changes.
labels: automerge
branch: actions/readme
base: master
- name: get repository name
if: ${{ steps.cpr.outputs.pull-request-number }}
shell: bash
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: automerge
if: ${{ steps.cpr.outputs.pull-request-number }}
uses: actions/[email protected]
with:
script: |
github.rest.pulls.merge({
owner: '${{ github.repository_owner }}',
repo: '${{ env.REPOSITORY_NAME }}',
pull_number: '${{ steps.cpr.outputs.pull-request-number }}',
sha: '${{ steps.cpr.outputs.pull-request-head-sha }}',
merge_method: 'merge'
})
downloadlist:
runs-on: ubuntu-latest
needs: artifacts
if: needs.artifacts.result == 'success'
steps:
- uses: actions/[email protected]
- name: Downloadlist
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
git fetch --depth 1 origin +refs/tags/artifacts:refs/tags/artifacts --no-tags
git restore --source=artifacts -- bin/ node_modules/ package-lock.json
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
bin/linux/x64/node/node-v$node_version-linux-x64/bin/node --use_strict index.js --readme_only
rm -r bin/
rm -r node_modules/
rm package-lock.json
git checkout -- README.html README.md
git add downloadlist.json
git -c user.name="GitHub" -c user.email="[email protected]" commit --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" -m"Update downloadlist" | sed -n 1p || true
if [[ $(git status --porcelain | tee /dev/stderr | head -c1 | wc -c) -ne 0 || $(git clean -dffx | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
- id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update downloadlist
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <[email protected]>
title: Update downloadlist
body: |
Update the downloadlist to reflect the latest changes.
labels: automerge
branch: actions/downloadlist
base: master
- name: get repository name
if: ${{ steps.cpr.outputs.pull-request-number }}
shell: bash
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: automerge
if: ${{ steps.cpr.outputs.pull-request-number }}
uses: actions/[email protected]
with:
script: |
github.rest.pulls.merge({
owner: '${{ github.repository_owner }}',
repo: '${{ env.REPOSITORY_NAME }}',
pull_number: '${{ steps.cpr.outputs.pull-request-number }}',
sha: '${{ steps.cpr.outputs.pull-request-head-sha }}',
merge_method: 'merge'
})
engines:
runs-on: ubuntu-latest
needs: artifacts
if: needs.artifacts.result == 'success'
steps:
- uses: actions/[email protected]
- name: Engines
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
git fetch --depth 1 origin +refs/tags/artifacts:refs/tags/artifacts --no-tags
git restore --source=artifacts -- bin/ node_modules/
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
sed -i "0,/\"npm\": \".*\"/s//\"npm\": \"$(cat bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/package.json | python -c "import sys, json; print(json.load(sys.stdin)['version'])") || $(cat node_modules/npm/package.json | python -c "import sys, json; print(json.load(sys.stdin)['version'])")\"/" package.json
rm -r bin/ node_modules/
- id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update engines
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <[email protected]>
title: Update engines
body: |
Update the engines field.
labels: automerge
branch: actions/engines
base: master
- name: get repository name
if: ${{ steps.cpr.outputs.pull-request-number }}
shell: bash
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: automerge
if: ${{ steps.cpr.outputs.pull-request-number }}
uses: actions/[email protected]
with:
script: |
github.rest.pulls.merge({
owner: '${{ github.repository_owner }}',
repo: '${{ env.REPOSITORY_NAME }}',
pull_number: '${{ steps.cpr.outputs.pull-request-number }}',
sha: '${{ steps.cpr.outputs.pull-request-head-sha }}',
merge_method: 'merge'
})
bundled:
runs-on: ubuntu-latest
needs: artifacts
if: needs.artifacts.result == 'success'
steps:
- uses: actions/[email protected]
- name: Bundled
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
git fetch --depth 1 origin +refs/tags/artifacts:refs/tags/artifacts --no-tags
git restore --source=artifacts -- node_modules/
sed -i -z 's| "bundleDependencies": \[\n ".*"\n \]| "bundleDependencies": \[\n'"$(printf ' "%s",\\n' $(find node_modules/ -mindepth 2 -maxdepth 3 -type f -name 'package.json' -exec bash -c 'path={}; echo "${path:13:-13}"' ';' | sort) | sed '$ s/...$//')"'\n \]|' -- 'package.json'
rm -r node_modules/
- id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update bundleDependencies
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <[email protected]>
title: Update bundleDependencies
body: |
Update the bundleDependencies field.
labels: automerge
branch: actions/bundled
base: master
- name: get repository name
if: ${{ steps.cpr.outputs.pull-request-number }}
shell: bash
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: automerge
if: ${{ steps.cpr.outputs.pull-request-number }}
uses: actions/[email protected]
with:
script: |
github.rest.pulls.merge({
owner: '${{ github.repository_owner }}',
repo: '${{ env.REPOSITORY_NAME }}',
pull_number: '${{ steps.cpr.outputs.pull-request-number }}',
sha: '${{ steps.cpr.outputs.pull-request-head-sha }}',
merge_method: 'merge'
})
artifacts_jsonlint:
runs-on: ubuntu-latest
needs: artifacts
if: needs.artifacts.result == 'success'
steps:
- name: Build demjson
shell: bash
run: |
pip install setuptools==57.5.0
pip install git+https://github.com/EIGHTFINITE/demjson.git@master
- uses: actions/[email protected]
with:
ref: artifacts
- name: jsonlint
shell: bash
run: |
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
# Forbid all
if [[ $(find . -type f -path ./.git -prune -o -path ./bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/node_modules/iconv-lite/encodings/tables -prune -o -path ./bin/windows/x64/node/node-v$node_version-win-x64/node_modules/npm/node_modules/iconv-lite/encodings/tables -prune -o -path ./node_modules/iconv-lite/encodings/tables -prune -o -path ./node_modules/npm-6/node_modules/iconv-lite/encodings/tables -prune -o -name '*.json' -exec jsonlint -s --forbid any-type-at-start,bom,duplicate-keys,non-portable,non-bmp,zero-byte -e utf8 -- '{}' ';' | grep -v -e ': ok' -e ': has errors' | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
# Allow non-bmp, zero-byte
if [[ $(find ./bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/node_modules/iconv-lite/encodings/tables ./bin/windows/x64/node/node-v$node_version-win-x64/node_modules/npm/node_modules/iconv-lite/encodings/tables ./node_modules/iconv-lite/encodings/tables ./node_modules/npm-6/node_modules/iconv-lite/encodings/tables -type f -name '*.json' -exec jsonlint -s --allow non-bmp,zero-byte --forbid any-type-at-start,bom,duplicate-keys,non-portable -e utf8 -- '{}' ';' | grep -v -e ': ok' -e ': has errors' | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
artifacts_install:
runs-on: ubuntu-latest
needs: artifacts
if: needs.artifacts.result == 'success'
steps:
- uses: actions/[email protected]
with:
ref: artifacts
path: DownloadItYourself
- name: install
shell: bash
run: |
cd DownloadItYourself
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
sed -i '/cache-max = 0/d' -- '.npmrc'
sed -i '/only = prod/d' -- '.npmrc'
sed -i '/optional = false/d' -- '.npmrc'
sed -i '/production = true/d' -- '.npmrc'
if [[ "$OSTYPE" == "msys" ]]; then
bin/windows/x64/node/node-v$node_version-win-x64/node.exe bin/windows/x64/node/node-v$node_version-win-x64/node_modules/npm/bin/npm-cli.js ls || true
else
cat bin/linux/x64/node/node-v$node_version-linux-x64/bin/node.* > bin/linux/x64/node/node-v$node_version-linux-x64/bin/node
chmod +x bin/linux/x64/node/node-v$node_version-linux-x64/bin/node
bin/linux/x64/node/node-v$node_version-linux-x64/bin/node bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/bin/npm-cli.js ls || true
rm bin/linux/x64/node/node-v$node_version-linux-x64/bin/node
fi
rm -rf .npm/
git checkout -- '.npmrc'
# Ignore peerDependencies
sed -i '/"peerDependencies": {/,/}/d' -- 'package.json'
cd ..
echo '{
"private": "true"
}' > package.json
cp DownloadItYourself/.npmrc .npmrc
if [[ "$OSTYPE" == "msys" ]]; then
DownloadItYourself/bin/windows/x64/node/node-v$node_version-win-x64/node.exe DownloadItYourself/bin/windows/x64/node/node-v$node_version-win-x64/node_modules/npm/bin/npm-cli.js install ./DownloadItYourself
else
cat DownloadItYourself/bin/linux/x64/node/node-v$node_version-linux-x64/bin/node.* > DownloadItYourself/bin/linux/x64/node/node-v$node_version-linux-x64/bin/node
chmod +x DownloadItYourself/bin/linux/x64/node/node-v$node_version-linux-x64/bin/node
DownloadItYourself/bin/linux/x64/node/node-v$node_version-linux-x64/bin/node DownloadItYourself/bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/bin/npm-cli.js install ./DownloadItYourself
rm DownloadItYourself/bin/linux/x64/node/node-v$node_version-linux-x64/bin/node
fi
rm -rf .npm/
artifacts_audit:
runs-on: ubuntu-latest
needs: [artifacts_install]
if: ${{ needs.artifacts_install.result == 'success' }}
steps:
- uses: actions/[email protected]
with:
ref: artifacts
- name: audit
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
bash --noprofile --norc -e -o pipefail docs/tools/actions-audit.sh
release:
runs-on: ubuntu-latest
needs: [artifacts_jsonlint, artifacts_audit]
if: ${{ needs.artifacts_jsonlint.result == 'success' && needs.artifacts_audit.result == 'success' }}
steps:
- uses: actions/[email protected]
with:
ref: artifacts
- name: Release
shell: bash
run: |
bash --noprofile --norc -e -o pipefail docs/tools/git-config.sh
export GIT_AUTHOR_DATE="$(git log -1 --format=%aD)"
export GIT_COMMITTER_DATE="$(git log -1 --format=%cD)"
# Update downloadlist files
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
# bin/linux/x64/node/node-v$node_version-linux-x64/bin/node --use_strict index.js --update_single_file_daily
git checkout -- 'README.html'
git checkout -- 'README.md'
git clean -ffx MultiMC/
git clean -ffx _download/
git clean -ffx minecraft/
git clean -ffx server/
if [[ $(git status --porcelain | tee /dev/stderr | head -c1 | wc -c) -ne 0 || $(git clean -dffx | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
# Release
git tag -f latest
git push -f origin refs/tags/latest:refs/tags/latest
release_jsonlint:
runs-on: ubuntu-latest
needs: release
if: needs.release.result == 'success'
steps:
- name: Build demjson
shell: bash
run: |
pip install setuptools==57.5.0
pip install git+https://github.com/EIGHTFINITE/demjson.git@master
- uses: actions/[email protected]
with:
ref: latest
- name: jsonlint
shell: bash
run: |
export node_version=$(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['engines']['node'])")
# Forbid all
if [[ $(find . -type f -path ./.git -prune -o -path ./bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/node_modules/iconv-lite/encodings/tables -prune -o -path ./bin/windows/x64/node/node-v$node_version-win-x64/node_modules/npm/node_modules/iconv-lite/encodings/tables -prune -o -path ./node_modules/iconv-lite/encodings/tables -prune -o -path ./node_modules/npm-6/node_modules/iconv-lite/encodings/tables -prune -o -name '*.json' -exec jsonlint -s --forbid any-type-at-start,bom,duplicate-keys,non-portable,non-bmp,zero-byte -e utf8 -- '{}' ';' | grep -v -e ': ok' -e ': has errors' | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi
# Allow non-bmp, zero-byte
if [[ $(find ./bin/linux/x64/node/node-v$node_version-linux-x64/lib/node_modules/npm/node_modules/iconv-lite/encodings/tables ./bin/windows/x64/node/node-v$node_version-win-x64/node_modules/npm/node_modules/iconv-lite/encodings/tables ./node_modules/iconv-lite/encodings/tables ./node_modules/npm-6/node_modules/iconv-lite/encodings/tables -type f -name '*.json' -exec jsonlint -s --allow non-bmp,zero-byte --forbid any-type-at-start,bom,duplicate-keys,non-portable -e utf8 -- '{}' ';' | grep -v -e ': ok' -e ': has errors' | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]
then exit 1
fi