From c3baac37f7327f97a8ca37f1924e3f6ed83f7b0b Mon Sep 17 00:00:00 2001
From: Miku <26039249+xMikux@users.noreply.github.com>
Date: Sun, 16 Oct 2022 14:14:34 +0800
Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B8=AC=E8=A9=A6=E6=96=B0=E8=A6=86?=
=?UTF-8?q?=E8=93=8B=E8=85=B3=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.github/scripts/assets_folder.sh | 44 +++++++
.github/scripts/override_mods.sh | 179 ++++++++++++++++++++++++++++
.github/workflows/Auto-Packer.yml | 88 +-------------
.github/workflows/CI_Release_Me.yml | 4 +
.gitignore | 4 -
5 files changed, 231 insertions(+), 88 deletions(-)
create mode 100644 .github/scripts/assets_folder.sh
create mode 100644 .github/scripts/override_mods.sh
diff --git a/.github/scripts/assets_folder.sh b/.github/scripts/assets_folder.sh
new file mode 100644
index 000000000..6d40b6a43
--- /dev/null
+++ b/.github/scripts/assets_folder.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+list_dir () {
+ find ../assets/ -maxdepth 1 -type d -exec echo "$1" \; > "$2"
+}
+
+readme_generate () {
+ file_name=readme_result.md
+ list_dir '
{}' $file_name
+ sed -i "s+../assets/++" $file_name
+ sed -i "s+../assets/minecraft++" $file_name
+ sed -i "s+../assets/++" $file_name
+ sed -i "/^$/d" $file_name
+}
+
+modslist_generate () {
+ file_name=modslist_result.md
+ list_dir '| {} | :x: | |' $file_name
+ sed -i "1s+| ../assets/ | :x: | |++" $file_name
+ sed -i "s+| {} | ../assets/minecraft | :x: | |++" $file_name
+ sed -i "s+../assets/++" $file_name
+ sed -i "/^$/d" $file_name
+}
+
+modslist_added_generate () {
+ file_name=modslist_result.md
+ x_placeholder=" | :x: | |"
+ x_x_placeholder=" | :x: |"
+ question_placeholder=" | :question: |"
+ check_placeholder=" | :heavy_check_mark: |"
+ # sed -i "s+MODNAME$x_placeholder+MODNAME$check_placeholder [已回饋]() |+" $file_name
+
+ sed -i "s+screencapper$x_placeholder+screencapper$check_placeholder [已回饋](https://github.com/Deftu/Screencapper/pull/6),但翻譯有變動,需再度 PR |+" $file_name
+ sed -i "s+sodium$x_placeholder+sodium$x_x_placeholder 由於 Crowdin 並未連上主專案進行同步翻譯 |+" $file_name
+ sed -i "s+sodium-extra$x_placeholder+sodium-extra$check_placeholder 已提交上 Crowdin |+" $file_name
+ sed -i "s+automodpack$x_placeholder+automodpack$check_placeholder [已回饋](https://github.com/Skidamek/AutoModpack/pull/64) |+" $file_name
+ sed -i "s+energymeter$x_placeholder+energymeter$question_placeholder [等待合併](https://github.com/AlmostReliable/energymeter-forge/pull/26) |+" $file_name
+ sed -i "s+fluxnetworks$x_placeholder+fluxnetworks$check_placeholder [已回饋](https://github.com/SonarSonic/Flux-Networks/pull/482),需要更新。 |+" $file_name
+ sed -i "s+trashcans$x_placeholder+trashcans$question_placeholder [等待合併](https://github.com/SuperMartijn642/TrashCans/pull/20) |+" $file_name
+}
+
+readme_generate
+modslist_generate
+modslist_added_generate
diff --git a/.github/scripts/override_mods.sh b/.github/scripts/override_mods.sh
new file mode 100644
index 000000000..19de6b504
--- /dev/null
+++ b/.github/scripts/override_mods.sh
@@ -0,0 +1,179 @@
+#!/bin/bash
+
+# shellcheck disable=2271,2260,2086
+
+echo ">>> 模組翻譯覆蓋腳本 <<<"
+echo ">>> 某些模組的翻譯如果搭配其他翻譯包"
+echo ">>> 所使用會將翻譯好的內容變成未翻譯"
+echo ">>> 此步驟將會把一些已知的模組翻譯覆蓋掉"
+
+home () {
+ cd "$GITHUB_WORKSPACE" || exit
+}
+
+mk_workdir () {
+ mkdir workdir
+ cd workdir || exit
+}
+
+rm_workdir () {
+ rm -r workdir
+}
+
+mega_override () {
+ mk_workdir
+ pwd
+
+ echo "小資訊:"
+ echo "megatools 並不知道原始連結是甚麼"
+ echo "這邊有一個修正連結的問題 https://github.com/megous/megatools/issues/157#issuecomment-615835778"
+
+ echo "安裝 megatools..."
+ sudo apt-get update
+ sudo apt-get install -y megatools
+
+ echo "覆蓋 $1..."
+
+ echo "設置 $2 路徑變數"
+ PATH_MEGA=$3
+
+ echo "下載 $1..."
+ megadl "$4"
+
+ echo "解壓縮 $5"
+ unzip "$5"
+
+ echo "回到工作目錄..."
+ cd ..
+
+ echo "移動 $1 的翻譯內容..."
+ mv workdir/$PATH_MEGA assets
+
+ echo "檢查 $1 覆蓋內容是否存在"
+ if [ -f "$PATH_MEGA/lang/zh_tw.json" ]; then
+ echo "翻譯存在!"
+ else
+ echo "錯誤!覆蓋 $1 翻譯失敗。"
+ exit 1
+ fi
+
+ echo "完成 $1 覆蓋!清理工作資料夾"
+ rm_workdir
+}
+
+
+mediafire_override () {
+ mk_workdir
+
+ echo "覆蓋 $1..."
+
+ echo "設置 $1 路徑變數"
+ PATH_MEDIAFIRE=$2
+
+ echo "下載 $1"
+ wget "$(wget -qO - "$3" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')"
+
+ echo "取出 $1 翻譯檔"
+ $JAVA_HOME_17_X64/bin/jar xf $4 $PATH_MEDIAFIRE/zh_tw.json
+
+ echo "回到工作目錄..."
+ cd ..
+
+ echo "創建 $1 語言資料夾..."
+ mkdir -p $PATH_MEDIAFIRE
+
+ echo "複製 $1 的翻譯內容..."
+ cp workdir/$PATH_MEDIAFIRE/zh_tw.json $PATH_MEDIAFIRE/
+
+ echo "檢查 $1 覆蓋內容是否存在"
+ if [ -f "$PATH_MEDIAFIRE/zh_tw.json" ]; then
+ echo "翻譯存在!"
+ else
+ echo "錯誤!覆蓋 $1 翻譯失敗。"
+ exit 1
+ fi
+
+ echo "完成 $1 覆蓋!清理工作資料夾"
+ rm_workdir
+}
+
+
+mediafire_tinker_override () {
+ mk_workdir
+
+ echo "覆蓋 $1..."
+
+ echo "設置 $1 路徑變數"
+ PATH_MEDIAFIRE_TINKER=$2
+ PATH_MEDIAFIRE_TINKER_BOOKS=$3
+
+ echo "下載 $1"
+ wget "$(wget -qO - "$4" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')"
+
+ echo "解壓縮 $1 Jar"
+ $JAVA_HOME_17_X64/bin/jar xf $5
+
+ echo "回到工作目錄..."
+ cd ..
+
+ echo "創建 $1 語言資料夾..."
+ mkdir -p $PATH_MEDIAFIRE_TINKER
+
+ echo "複製 $1 的翻譯內容..."
+ cp workdir/$PATH_MEDIAFIRE_TINKER/zh_tw.json $PATH_MEDIAFIRE_TINKER/
+
+ echo "創建 $1 書本資料夾"
+ mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/tinkers_gadgetry
+ mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/puny_smelting
+ mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/mighty_smelting
+ mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/materials_and_you
+ mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/fantastic_foundry
+ mkdir -p $PATH_MEDIAFIRE_TINKER_BOOKS/encyclopedia
+
+ echo "複製 $1 的書本內容..."
+ cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/tinkers_gadgetry/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/tinkers_gadgetry
+ cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/puny_smelting/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/puny_smelting
+ cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/mighty_smelting/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/mighty_smelting
+ cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/materials_and_you/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/materials_and_you
+ cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/fantastic_foundry/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/fantastic_foundry
+ cp -r workdir/$PATH_MEDIAFIRE_TINKER_BOOKS/encyclopedia/zh_tw $PATH_MEDIAFIRE_TINKER_BOOKS/encyclopedia
+
+ echo "檢查 $1 覆蓋內容是否存在"
+ if [ -f "$PATH_MEDIAFIRE_TINKER/zh_tw.json" ]; then
+ echo "翻譯存在!"
+ else
+ echo "錯誤!覆蓋 $1 翻譯失敗。"
+ exit 1
+ fi
+
+ echo "完成 $1 覆蓋!清理工作資料夾"
+ rm_workdir
+}
+
+
+# Main
+
+## 回到工作目錄
+home
+
+## Mega
+
+### BloodMagic
+mega_override "BloodMagic" "BLOODMAGIC" "assets/bloodmagic" "https://mega.nz/#!KR0CQC5Z!MkEdb3M5q9FHLIgY7WLE18T8EqKFMVUd1guryQWdTQc" "1.18 BloodMagic-zh_tw-v2.zip"
+echo "修正 BloodMagic 的全形空格"
+sed -i 's/ //1' assets/bloodmagic/patchouli_books/guide/zh_tw/entries/altar/soul_network.json
+
+## Mediafire
+
+### ProjectE
+mediafire_override "ProjectE" "assets/projecte/lang" "https://www.mediafire.com/file/uhtspihpscmrqsb/ProjectE-1.19.2-PE1.0.1B-tw.jar" "ProjectE-1.19.2-PE1.0.1B-tw.jar"
+
+### The Twilight Forest
+mediafire_override "The Twilight Forest" "assets/twilightforest/lang" "https://www.mediafire.com/file/kl96rxo50e68j93/twilightforest-1.18.2-4.1.1423-universal-tw.jar" "twilightforest-1.18.2-4.1.1423-universal-tw.jar"
+
+### Productive Bees
+mediafire_override "Productive Bees" "assets/productivebees/lang" "https://www.mediafire.com/file/raz0dqfohs5jk29/productivebees-1.19.2-0.10.2.0-tw.jar" "productivebees-1.19.2-0.10.2.0-tw.jar"
+
+### Tinker (特殊)
+
+mediafire_tinker_override "Tinkers' Construct" "assets/tconstruct/lang" "assets/tconstruct/book" "https://www.mediafire.com/file/snogv3qqn57o8rf/TConstruct-1.18.2-3.5.2.40-tw.jar" "TConstruct-1.18.2-3.5.2.40-tw.jar"
diff --git a/.github/workflows/Auto-Packer.yml b/.github/workflows/Auto-Packer.yml
index 6db3ecc1c..ce381c537 100644
--- a/.github/workflows/Auto-Packer.yml
+++ b/.github/workflows/Auto-Packer.yml
@@ -9,6 +9,9 @@ on:
- pack.mcmeta
workflow_dispatch: {}
+permissions:
+ contents: write
+
jobs:
Packer:
runs-on: ubuntu-latest
@@ -34,90 +37,7 @@ jobs:
# wget https://raw.githubusercontent.com/Creators-of-Create/Create/mc1.18/dev/src/main/resources/assets/create/lang/zh_tw.json -P $PATH_Create
- name: Override mods
- run: |
- echo ">>> 模組翻譯覆蓋 <<<"
- echo ">>> 某些模組的翻譯如果搭配其他翻譯包"
- echo ">>> 所使用會將翻譯好的內容變成未翻譯"
- echo ">>> 此步驟將會把一些已知的模組翻譯覆蓋掉"
-
- echo "Override ProjectE..."
- PATH_ProjectE=assets/projecte/lang
- mkdir -p $PATH_ProjectE
- mkdir workdir
- cd workdir
- wget $(wget -qO - "https://www.mediafire.com/file/uhtspihpscmrqsb/ProjectE-1.19.2-PE1.0.1B-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
- $JAVA_HOME_17_X64/bin/jar xf ProjectE-1.19.2-PE1.0.1B-tw.jar $PATH_ProjectE/zh_tw.json
- cd ..
- cp workdir/$PATH_ProjectE/zh_tw.json $PATH_ProjectE/
- rm -r workdir
-
- echo "Override BloodMagic..."
- mkdir workdir
- cd workdir
- sudo apt-get update
- sudo apt-get install -y megatools
- echo "Small Info:"
- echo "The original download link is https://mega.nz/file/KR0CQC5Z#MkEdb3M5q9FHLIgY7WLE18T8EqKFMVUd1guryQWdTQc"
- echo "But megatools look like don't know what is this"
- echo "This fix I see from https://github.com/megous/megatools/issues/157#issuecomment-615835778"
- megadl 'https://mega.nz/#!KR0CQC5Z!MkEdb3M5q9FHLIgY7WLE18T8EqKFMVUd1guryQWdTQc'
- unzip 1.18\ BloodMagic-zh_tw-v2.zip
- cd ..
- mv workdir/assets/bloodmagic assets
- rm -r workdir
- echo "Fix error space"
- sed -i 's/ //1' assets/bloodmagic/patchouli_books/guide/zh_tw/entries/altar/soul_network.json
-
- echo "Override Tinkers' Construct..."
- PATH_TConstruct=assets/tconstruct/lang
- PATH_TConstruct_Books=assets/tconstruct/book
- mkdir -p $PATH_TConstruct
- mkdir workdir
- cd workdir
- wget $(wget -qO - "https://www.mediafire.com/file/snogv3qqn57o8rf/TConstruct-1.18.2-3.5.2.40-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
- $JAVA_HOME_17_X64/bin/jar xf TConstruct-1.18.2-3.5.2.40-tw.jar
- cd ..
- cp workdir/$PATH_TConstruct/zh_tw.json $PATH_TConstruct/
- echo ">> Tinkers' Construct Books"
- echo ">> Setup folders..."
- mkdir -p $PATH_TConstruct_Books/tinkers_gadgetry
- mkdir -p $PATH_TConstruct_Books/puny_smelting
- mkdir -p $PATH_TConstruct_Books/mighty_smelting
- mkdir -p $PATH_TConstruct_Books/materials_and_you
- mkdir -p $PATH_TConstruct_Books/fantastic_foundry
- mkdir -p $PATH_TConstruct_Books/encyclopedia
- echo ">> Setup folder done!"
- echo ">> Copy Tinkers' Construct Books"
- cp -r workdir/$PATH_TConstruct_Books/tinkers_gadgetry/zh_tw $PATH_TConstruct_Books/tinkers_gadgetry
- cp -r workdir/$PATH_TConstruct_Books/puny_smelting/zh_tw $PATH_TConstruct_Books/puny_smelting
- cp -r workdir/$PATH_TConstruct_Books/mighty_smelting/zh_tw $PATH_TConstruct_Books/mighty_smelting
- cp -r workdir/$PATH_TConstruct_Books/materials_and_you/zh_tw $PATH_TConstruct_Books/materials_and_you
- cp -r workdir/$PATH_TConstruct_Books/fantastic_foundry/zh_tw $PATH_TConstruct_Books/fantastic_foundry
- cp -r workdir/$PATH_TConstruct_Books/encyclopedia/zh_tw $PATH_TConstruct_Books/encyclopedia
- echo ">> Copy books done!"
- rm -r workdir
-
- echo "Override The Twilight Forest..."
- PATH_TwilightForest=assets/twilightforest/lang
- mkdir -p $PATH_TwilightForest
- mkdir workdir
- cd workdir
- wget $(wget -qO - "https://www.mediafire.com/file/kl96rxo50e68j93/twilightforest-1.18.2-4.1.1423-universal-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
- $JAVA_HOME_17_X64/bin/jar xf twilightforest-1.18.2-4.1.1423-universal-tw.jar $PATH_TwilightForest/zh_tw.json
- cd ..
- cp workdir/$PATH_TwilightForest/zh_tw.json $PATH_TwilightForest/
- rm -r workdir
-
- echo "Override Productive Bees..."
- PATH_ProductiveBees=assets/productivebees/lang
- mkdir -p $PATH_ProductiveBees
- mkdir workdir
- cd workdir
- wget $(wget -qO - "https://www.mediafire.com/file/raz0dqfohs5jk29/productivebees-1.19.2-0.10.2.0-tw.jar" > /dev/stdout | grep 'id="downloadButton"' | grep -Po '(?<=href=")[^"]*')
- $JAVA_HOME_17_X64/bin/jar xf productivebees-1.19.2-0.10.2.0-tw.jar $PATH_ProductiveBees/zh_tw.json
- cd ..
- cp workdir/$PATH_ProductiveBees/zh_tw.json $PATH_ProductiveBees/
- rm -r workdir
+ run: sh .github/scripts/override_mods.sh
- name: Make ModsTranslationPack (1.19.x)
uses: ComunidadAylas/PackSquash-action@master
diff --git a/.github/workflows/CI_Release_Me.yml b/.github/workflows/CI_Release_Me.yml
index 728d1797d..b28c62126 100644
--- a/.github/workflows/CI_Release_Me.yml
+++ b/.github/workflows/CI_Release_Me.yml
@@ -6,6 +6,10 @@ on:
- main
workflow_dispatch: {}
+permissions:
+ contents: write
+ pull-requests: write
+
jobs:
release-please:
name: Release Please
diff --git a/.gitignore b/.gitignore
index 82eb9ea07..9403190cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,3 @@
# Ignore Minecraft Lang Files
docs/Minecraft-Lang
-
-# Ignore My Tools
-
-tools
\ No newline at end of file