2 set -o errexit -o nounset
4 # -----------------------------------------------------------------------------
7 readonly mc_version="1.7.10"
8 readonly master_site="https://gregtech.overminddl1.com/com/gregoriust/gregtech/gregtech_${mc_version}"
9 readonly workdir="_work"
11 # -----------------------------------------------------------------------------
18 echo >&2 "Usage: $0 [-d] VERSION"
20 while getopts dh OPT; do
32 if (( $# == 0 )); then
38 # -----------------------------------------------------------------------------
42 # Is the /dev/stdout a tty?
44 echo -ne "\e[1;32m" # bold + green
51 if (( ! $dry_run )); then
57 # Is the /dev/stdout a tty?
59 echo -ne "\e[1;33m" # bold + yellow
67 # -----------------------------------------------------------------------------
68 # Downloading distribution files
70 msg "=> Importing GregTech ${gt_version}"
71 if (( $dry_run )); then
72 msg "=> -d (dry-run) is in effect. No actual changes will be made."
74 msg -n "=> Type [RET] to continue..."
78 readonly mod_jar="gregtech_${mc_version}-${gt_version}.jar"
79 readonly api_jar="gregtech_${mc_version}-${gt_version}-sources.jar"
80 mkdir -p "${workdir}/dist"
82 msg "==> Downloading ${mod_jar}"
83 run curl "${master_site}/${gt_version}/${mod_jar}" -o "${workdir}/dist/${mod_jar}" --time-cond "${workdir}/dist/${mod_jar}" --continue-at -
85 msg "==> Downloading ${api_jar}"
86 run curl "${master_site}/${gt_version}/${api_jar}" -o "${workdir}/dist/${api_jar}" --time-cond "${workdir}/dist/${api_jar}" --continue-at -
88 # -----------------------------------------------------------------------------
91 msg "==> Decompiling ${mod_jar}"
92 run cfr "${workdir}/dist/${mod_jar}" --outputdir .
94 # -----------------------------------------------------------------------------
95 # Unpacking API sources
97 msg "==> Unpacking API sources"
98 run jar -xf "${workdir}/dist/${api_jar}" gregapi
100 # -----------------------------------------------------------------------------
103 msg "==> Unpacking assets"
104 run jar -xf "${workdir}/dist/${mod_jar}" assets
106 # -----------------------------------------------------------------------------
107 # Creating a commit and a tag
109 msg "==> Creating a commit"
112 run git commit --message "Import GregTech ${gt_version}"
114 msg "==> Tagging the commit"
115 run git tag --annotate --message "GregTech ${gt_version} (Official)" "GregTech-${gt_version}"