-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.95 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
name: Build
on:
schedule:
- cron: '30 18 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install coreutils curl findutils gawk jq libjson-perl perl sed unzip zip
- name: Cache version information
run: |
curl -L https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq '.versions[0] | "\(.id) \(.url)"' | sed -e 's/"//g' -e 's/ /\t/g' > version_info.txt
- name: Check update
run: |
if [ ! -f pack.mcmeta ]; then
echo changes_exist=true >> $GITHUB_ENV
else
if [ $(cat pack.mcmeta | jq .pack.description | sed -e 's/"//g' -e 's/^.*(//' -e 's/)$//') != $(cut -f1 version_info.txt) ]; then
echo changes_exist=true >> $GITHUB_ENV
fi
fi
- name: Validate update
if: env.changes_exist == 'true'
run: |
if [ ! $(cut -f1 version_info.txt | grep -P '^\d{2}w\d{2}[a-z]$|^1(?:.\d+?){1,2}-(?:pre|rc)\d+$|^1(?:.\d+?){1,2}$') ]; then
echo changes_exist=false >> $GITHUB_ENV
fi
- name: Download client
if: env.changes_exist == 'true'
run: |
cut -f2 version_info.txt | xargs curl -L | jq .downloads.client.url | xargs curl -Lo source.jar
- name: Extract files
if: env.changes_exist == 'true'
run: |
unzip source.jar assets/minecraft/lang/en_us.json version.json
- name: Generate language file
if: env.changes_exist == 'true'
run: |
./generator/generate < assets/minecraft/lang/en_us.json > assets/minecraft/lang/key.json
- name: Generate pack.mcmeta
if: env.changes_exist == 'true'
run: |
cat version.json | jq .pack_version.resource,.id | sed 's/"//g' | tr '\n' '\t' | awk '{print "sed -e \"s/#PACKFORMAT/"$1"/g\" -e \"s/#VERSION/"$2"/g\" pack.mcmeta.example > pack.mcmeta"}' | bash
- name: Get Minecraft version
if: env.changes_exist == 'true'
run: |
echo "ver=$(cat version.json | jq .id | sed 's/\"//g')" >> "$GITHUB_ENV"
- name: Update repository
if: env.changes_exist == 'true'
uses: EndBug/add-and-commit@v9
with:
add: 'assets/minecraft/lang/key.json pack.mcmeta'
default_author: github_actions
message: "${{ env.ver }}"
- name: Create pack
if: env.changes_exist == 'true'
run: |
zip -r keypack.zip assets/minecraft/lang/key.json pack.mcmeta
- name: Release pack
if: env.changes_exist == 'true'
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.ver }}"
title: "${{ env.ver }}"
prerelease: true
files: |
keypack.zip