Skip to content

Build

Build #220

Workflow file for this run

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