Update scripts

This commit is contained in:
William Blake Galbreath
2020-03-27 01:36:19 -05:00
parent 8abc38c01d
commit d748256635
10 changed files with 306 additions and 350 deletions

27
purpur
View File

@@ -7,9 +7,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}") SOURCE=$([[ "$SOURCE" == /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE") basedir=$(dirname "$SOURCE")
. $basedir/scripts/init.sh . "$basedir"/scripts/init.sh
purpurstash() { purpurstash() {
STASHED=$(git stash) STASHED=$(git stash)
@@ -22,15 +22,15 @@ purpurunstash() {
} }
case "$1" in case "$1" in
"a" | "am" | "amend") "am" | "amend")
( (
cd $basedir/Purpur-API/ cd "$basedir"/Purpur-API/
git add . git add .
git commit --amend --no-edit git commit --amend --no-edit
cd $basedir/Purpur-Server/ cd "$basedir"/Purpur-Server/
git add . git add .
git commit --amend --no-edit git commit --amend --no-edit
cd $basedir cd "$basedir"
scripts/rebuildpatches.sh "$basedir" scripts/rebuildpatches.sh "$basedir"
) )
;; ;;
@@ -52,8 +52,10 @@ case "$1" in
( (
basedir basedir
mvn -N install mvn -N install
cd ${FORK_NAME}-API cd Purpur-API
mvn -e clean install && cd ../${FORK_NAME}-Server && mvn -e clean install mvn -e clean install
cd ../Purpur-Server
mvn -e clean install
) )
;; ;;
"jar" | "purpurclip") "jar" | "purpurclip")
@@ -71,8 +73,10 @@ case "$1" in
( (
basedir basedir
mvn -N install mvn -N install
cd ${FORK_NAME}-API cd Purpur-API
mvn clean deploy && cd ../${FORK_NAME}-Server && mvn clean install mvn clean deploy
cd ../Purpur-Server
mvn clean install
) )
;; ;;
"up" | "upstream") "up" | "upstream")
@@ -93,7 +97,7 @@ case "$1" in
"setup") "setup")
if [[ -f ~/.bashrc ]]; then if [[ -f ~/.bashrc ]]; then
NAME="purpur" NAME="purpur"
if [[ ! -z "${2+x}" ]] ; then if [[ -n "${2+x}" ]]; then
NAME="$2" NAME="$2"
fi fi
(grep "alias $NAME=" ~/.bashrc >/dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >>~/.bashrc) (grep "alias $NAME=" ~/.bashrc >/dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >>~/.bashrc)
@@ -107,6 +111,7 @@ case "$1" in
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup." echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
echo "" echo ""
echo " Normal commands:" echo " Normal commands:"
echo " * am, amend | Amend current edits to last patches"
echo " * rb, rebuild | Rebuild patches, can be called from anywhere." echo " * rb, rebuild | Rebuild patches, can be called from anywhere."
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere." echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere." echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere."

View File

@@ -22,7 +22,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
PS1="$" PS1="$"
paperVer=$(cat current-paper) paperVer=$(cat current-paper)
@@ -30,24 +30,24 @@ gpgsign="$(git config commit.gpgsign || echo "false")"
echo "Rebuilding Forked projects.... " echo "Rebuilding Forked projects.... "
function applyPatch { function applyPatch {
what=$1 what=$1
what_name=$(basename $what) what_name=$(basename "$what")
target=$2 target=$2
branch=$3 branch=$3
patch_folder=$4 patch_folder=$4
cd "$basedir/$what" cd "$basedir/$what" || exit
git fetch --all git fetch --all
git branch -f upstream "$branch" >/dev/null git branch -f upstream "$branch" >/dev/null
cd "$basedir" cd "$basedir" || exit
if [ ! -d "$basedir/$target" ]; then if [ ! -d "$basedir/$target" ]; then
mkdir "$basedir/$target" mkdir "$basedir/$target"
cd "$basedir/$target" cd "$basedir/$target" || exit
git init git init
git remote add origin $5 git remote add origin "$5"
cd "$basedir" cd "$basedir" || exit
fi fi
cd "$basedir/$target" cd "$basedir/$target" || exit
# Disable GPG signing before AM, slows things down and doesn't play nicely. # Disable GPG signing before AM, slows things down and doesn't play nicely.
# There is also zero rational or logical reason to do so for these sub-repo AMs. # There is also zero rational or logical reason to do so for these sub-repo AMs.
@@ -56,7 +56,7 @@ function applyPatch {
echo "Resetting $target to $what_name..." echo "Resetting $target to $what_name..."
git remote rm upstream > /dev/null 2>&1 git remote rm upstream > /dev/null 2>&1
git remote add upstream $basedir/$what >/dev/null 2>&1 git remote add upstream "$basedir"/"$what" >/dev/null 2>&1
git checkout master 2>/dev/null || git checkout -b master git checkout master 2>/dev/null || git checkout -b master
git fetch upstream >/dev/null 2>&1 git fetch upstream >/dev/null 2>&1
git reset --hard upstream/upstream git reset --hard upstream/upstream
@@ -80,8 +80,8 @@ function enableCommitSigningIfNeeded {
} }
( (
(applyPatch Paper/Paper-API ${FORK_NAME}-API HEAD api $API_REPO && (applyPatch Paper/Paper-API Purpur-API HEAD api "$API_REPO" &&
applyPatch Paper/Paper-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO) || exit 1 applyPatch Paper/Paper-Server Purpur-Server HEAD server "$SERVER_REPO") || exit 1
enableCommitSigningIfNeeded enableCommitSigningIfNeeded
) || ( ) || (
echo "Failed to apply patches" echo "Failed to apply patches"

View File

@@ -6,35 +6,32 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
cd "$basedir" || exit
cd $basedir
paperVer=$(cat current-paper) paperVer=$(cat current-paper)
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
decompile="Paper/work/Minecraft/$minecraftversion/spigot" decompile="Paper/work/Minecraft/$minecraftversion/spigot"
mkdir -p mc-dev/src/net/minecraft/server mkdir -p mc-dev/src/net/minecraft/server
cd mc-dev cd mc-dev || exit
if [ ! -d ".git" ]; then if [ ! -d ".git" ]; then
git init git init
fi fi
rm src/net/minecraft/server/*.java rm src/net/minecraft/server/*.java
cp $basedir/$decompile/net/minecraft/server/*.java src/net/minecraft/server cp "$basedir"/"$decompile"/net/minecraft/server/*.java src/net/minecraft/server
base="$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server" base="$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server"
cd $basedir/mc-dev/src/net/minecraft/server/ cd "$basedir"/mc-dev/src/net/minecraft/server/ || exit
for file in $(/bin/ls $base) for file in $(/bin/ls "$base"); do
do
if [ -f "$file" ]; then if [ -f "$file" ]; then
rm -f "$file" rm -f "$file"
fi fi
done done
cd $basedir/mc-dev cd "$basedir"/mc-dev || exit
git add . -A git add . -A
git commit . -m "mc-dev" git commit . -m "mc-dev"
git tag -a "$paperVer" -m "$paperVer" 2>/dev/null git tag -a "$paperVer" -m "$paperVer" 2>/dev/null
pushRepo . $MCDEV_REPO $paperVer

View File

@@ -6,26 +6,26 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
workdir=$basedir/Paper/work workdir=$basedir/Paper/work
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
decompiledir=$workdir/Minecraft/$minecraftversion/spigot decompiledir=$workdir/Minecraft/$minecraftversion/spigot
nms="net/minecraft/server" nms="net/minecraft/server"
export MODLOG="" export MODLOG=""
cd $basedir cd "$basedir" || exit
function containsElement { function containsElement() {
local e local e
for e in "${@:2}"; do for e in "${@:2}"; do
[[ "$e" == "$1" ]] && return 0; [[ "$e" == "$1" ]] && return 0
done done
return 1 return 1
} }
export importedmcdev="" export importedmcdev=""
function import { function import() {
if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then
echo "ALREADY IMPORTED $1" echo "ALREADY IMPORTED $1"
return 0 return 0
@@ -36,7 +36,7 @@ function import {
base="$decompiledir/$nms/$file" base="$decompiledir/$nms/$file"
if [[ ! -f "$target" ]]; then if [[ ! -f "$target" ]]; then
export MODLOG="$MODLOG Imported $file from mc-dev\n"; export MODLOG="$MODLOG Imported $file from mc-dev\n"
echo "$(bashColor 1 32) Copying $(bashColor 1 34)$base $(bashColor 1 32)to$(bashColor 1 34) $target $(bashColorReset)" echo "$(bashColor 1 32) Copying $(bashColor 1 34)$base $(bashColor 1 32)to$(bashColor 1 34) $target $(bashColorReset)"
cp "$base" "$target" cp "$base" "$target"
else else
@@ -45,26 +45,25 @@ function import {
} }
( (
cd Paper/Paper-Server/ cd Paper/Paper-Server/ || exit
lastlog=$(git log -1 --oneline) lastlog=$(git log -1 --oneline)
if [[ "$lastlog" = *"Purpur-Extra mc-dev Imports"* ]]; then if [[ "$lastlog" == *"Purpur-Extra mc-dev Imports"* ]]; then
git reset --hard HEAD^ git reset --hard HEAD^
fi fi
) )
files=$(cat patches/server/* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') files=$(cat patches/server/* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g')
nonnms=$(cat patches/server/* | grep "create mode " | grep -Po "src/main/java/net/minecraft/server/(.*?).java" | sort | uniq | sed 's/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') nonnms=$(cat patches/server/* | grep "create mode " | grep -Po "src/main/java/net/minecraft/server/(.*?).java" | sort | uniq | sed 's/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g')
for f in $files; do for f in $files; do
containsElement "$f" ${nonnms[@]} containsElement "$f" "${nonnms[@]}"
if [ "$?" == "1" ]; then if [ "$?" == "1" ]; then
if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then
if [ ! -f "$decompiledir/$nms/$f.java" ]; then if [ ! -f "$decompiledir/$nms/$f.java" ]; then
echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"; echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"
else else
import $f import "$f"
fi fi
fi fi
fi fi
@@ -80,10 +79,8 @@ done
################ ################
( (
cd Paper/Paper-Server/ cd Paper/Paper-Server/ || exit
rm -rf nms-patches rm -rf nms-patches
git add src -A git add src -A
echo -e "Purpur-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F - echo -e "Purpur-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F -
) )

View File

@@ -1,36 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# BEGIN config
FORK_NAME="Purpur"
API_REPO=""
SERVER_REPO=""
PAPER_API_REPO=""
PAPER_SERVER_REPO=""
MCDEV_REPO=""
# END config
sourceBase=$(dirname $SOURCE)/../ sourceBase=$(dirname "$SOURCE")/../
cd ${basedir:-$sourceBase} cd "${basedir:-$sourceBase}" || exit
basedir=$(pwd -P) basedir=$(pwd -P)
cd - cd - || exit
function bashColor() {
function bashColor { if [ "$2" ]; then
if [ $2 ]; then
echo -e "\e[$1;$2m" echo -e "\e[$1;$2m"
else else
echo -e "\e[$1m" echo -e "\e[$1m"
fi fi
} }
function bashColorReset { function bashColorReset() {
echo -e "\e[m" echo -e "\e[m"
} }
function cleanupPatches { function cleanupPatches() {
cd "$1" cd "$1" || exit
for patch in *.patch; do for patch in *.patch; do
gitver=$(tail -n 2 $patch | grep -ve "^$" | tail -n 1) gitver=$(tail -n 2 "$patch" | grep -ve "^$" | tail -n 1)
diffs=$(git diff --staged $patch | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index|Date\: )") diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index|Date\: )")
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver") testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then if [ "x$testver" != "x" ]; then
@@ -38,28 +29,17 @@ function cleanupPatches {
fi fi
if [ "x$diffs" == "x" ]; then if [ "x$diffs" == "x" ]; then
git reset HEAD $patch >/dev/null git reset HEAD "$patch" >/dev/null
git checkout -- $patch >/dev/null git checkout -- "$patch" >/dev/null
fi fi
done done
} }
function pushRepo { function basedir() {
if [ "$(git config minecraft.push-${FORK_NAME})" == "1" ]; then cd "$basedir" || exit
echo "Pushing - $1 ($3) to $2"
(
cd "$1"
git remote rm emc-push > /dev/null 2>&1
git remote add emc-push $2 >/dev/null 2>&1
git push emc-push $3 -f
)
fi
} }
function basedir { function gethead() {
cd "$basedir"
}
function gethead {
( (
cd "$1" cd "$1" || exit
git log -1 --oneline git log -1 --oneline
) )
} }

View File

@@ -1,10 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
( (
set -e set -e
basedir="$(cd "$1" && pwd -P)" basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/Paper/work" workdir="$basedir/Paper/work"
mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) mcver=$(< "$workdir/BuildData/info.json" grep minecraftVersion | cut -d '"' -f 4)
purpurjar="$basedir/Purpur-Server/target/purpur-$mcver.jar" purpurjar="$basedir/Purpur-Server/target/purpur-$mcver.jar"
vanillajar="$workdir/Minecraft/$mcver/$mcver.jar" vanillajar="$workdir/Minecraft/$mcver/$mcver.jar"

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. $(dirname $SOURCE)/init.sh
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
basedir
pushRepo ${FORK_NAME}-API $API_REPO master:$minecraftversion
pushRepo ${FORK_NAME}-Server $SERVER_REPO master:$minecraftversion

View File

@@ -6,39 +6,36 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
PS1="$" PS1="$"
echo "Rebuilding patch files from current fork state..." echo "Rebuilding patch files from current fork state..."
function savePatches { function savePatches() {
what=$1 what=$1
cd $basedir/$what/ cd "$basedir"/"$what"/ || exit
mkdir -p $basedir/patches/$2 mkdir -p "$basedir"/patches/"$2"
if [ -d ".git/rebase-apply" ]; then if [ -d ".git/rebase-apply" ]; then
# in middle of a rebase, be smarter # in middle of a rebase, be smarter
echo "REBASE DETECTED - PARTIAL SAVE" echo "REBASE DETECTED - PARTIAL SAVE"
last=$(cat ".git/rebase-apply/last") last=$(cat ".git/rebase-apply/last")
next=$(cat ".git/rebase-apply/next") next=$(cat ".git/rebase-apply/next")
declare -a files=("$basedir/patches/$2/"*.patch) declare -a files=("$basedir/patches/$2/"*.patch)
for i in $(seq -f "%04g" 1 1 $last) for i in $(seq -f "%04g" 1 1 "$last"); do
do if [ "$i" -lt "$next" ]; then
if [ $i -lt $next ]; then rm "${files[$(("$i" - 1))]}"
rm "${files[`expr $i - 1`]}"
fi fi
done done
else else
rm $basedir/patches/$2/*.patch rm "$basedir"/patches/"$2"/*.patch
fi fi
git format-patch --quiet -N -o $basedir/patches/$2 upstream/upstream git format-patch --quiet -N -o "$basedir"/patches/"$2" upstream/upstream
cd $basedir cd "$basedir" || exit
git add -A $basedir/patches/$2 git add -A "$basedir"/patches/"$2"
cleanupPatches $basedir/patches/$2/ cleanupPatches "$basedir"/patches/"$2"/
echo " Patches saved for $what to patches/$2" echo " Patches saved for $what to patches/$2"
} }
savePatches ${FORK_NAME}-API api savePatches Purpur-API api
savePatches ${FORK_NAME}-Server server savePatches Purpur-Server server
$basedir/scripts/push.sh

View File

@@ -6,11 +6,11 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
if [[ "$1" == up* ]]; then if [[ "$1" == up* ]]; then
( (
cd "$basedir/Paper/" cd "$basedir/Paper/" || exit
git fetch && git reset --hard origin/master git fetch && git reset --hard origin/master
cd ../ cd ../
git add Paper git add Paper
@@ -18,28 +18,28 @@ if [[ "$1" == up* ]]; then
fi fi
paperVer=$(gethead Paper) paperVer=$(gethead Paper)
cd "$basedir/Paper/" cd "$basedir/Paper/" || exit
./paper patch ./paper patch
cd "Paper-Server" cd "Paper-Server" || exit
mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=minecraft_version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }') mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=minecraft_version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }')
basedir basedir
. $basedir/scripts/importmcdev.sh . "$basedir"/scripts/importmcdev.sh
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev") version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev")
tag="${minecraftversion}-${mcVer}-$(echo -e $version | shasum | awk '{print $1}')" tag="${minecraftversion}-${mcVer}-$(echo -e "$version" | shasum | awk '{print $1}')"
echo "$tag" > $basedir/current-paper echo "$tag" >"$basedir"/current-paper
$basedir/scripts/generatesources.sh "$basedir"/scripts/generatesources.sh
cd Paper/ cd Paper/ || exit
function tag { function tag() {
( (
cd $1 cd "$1" || exit
if [ "$2" == "1" ]; then if [ "$2" == "1" ]; then
git tag -d "$tag" 2>/dev/null git tag -d "$tag" 2>/dev/null
fi fi
@@ -50,13 +50,9 @@ echo "Tagging as $tag"
echo -e "$version" echo -e "$version"
forcetag=0 forcetag=0
if [ "$(cat $basedir/current-paper)" != "$tag" ]; then if [ "$(cat "$basedir"/current-paper)" != "$tag" ]; then
forcetag=1 forcetag=1
fi fi
tag Paper-API $forcetag tag Paper-API $forcetag
tag Paper-Server $forcetag tag Paper-Server $forcetag
pushRepo Paper-API $PAPER_API_REPO $tag
pushRepo Paper-Server $PAPER_SERVER_REPO $tag

View File

@@ -4,24 +4,24 @@ set -e
PS1="$" PS1="$"
function changelog() { function changelog() {
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1) base=$(git ls-tree HEAD "$1" | cut -d' ' -f3 | cut -f1)
cd $1 && git log --oneline ${base}...HEAD cd "$1" && git log --oneline "${base}"...HEAD
} }
paper=$(changelog Paper) paper=$(changelog Paper)
updated="" updated=""
logsuffix="" logsuffix=""
if [ ! -z "$paper" ]; then if [ -n "$paper" ]; then
logsuffix="$logsuffix\n\nPaper Changes:\n$paper" logsuffix="$logsuffix\n\nPaper Changes:\n$paper"
if [ -z "$updated" ]; then updated="Paper"; else updated="$updated/Paper"; fi if [ -z "$updated" ]; then updated="Paper"; else updated="$updated/Paper"; fi
fi fi
disclaimer="Upstream has released updates that appears to apply and compile correctly" disclaimer="Upstream has released updates that appears to apply and compile correctly"
if [ ! -z "$1" ]; then if [ -n "$1" ]; then
disclaimer="$@" disclaimer=( "$@" )
fi fi
log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}" log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer[*]}${logsuffix}"
echo -e "$log" | git commit -F - echo -e "$log" | git commit -F -