-
Notifications
You must be signed in to change notification settings - Fork 12
/
build-release.sh
executable file
·115 lines (102 loc) · 3.33 KB
/
build-release.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
cd "${0%/*}" # make sure we're in the right directory
while getopts ":s" opt; do
case $opt in
s)
_steamupload=1
_steamuser=$(cat ./steamuser)
#sudo true # elevate ahead of time
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
cmthash=$(git rev-parse --short HEAD)
unameOut="$(uname -s)"
case "${unameOut}" in
CYGWIN*) ;& # windows... I don't know where the heck you'll have this
MINGW*) ;;
*) _asset_packer="$HOME/.local/share/Steam/steamapps/common/Starbound/linux/asset_packer" ;;
esac
asset_packer () {
"$_asset_packer" "$@"
}
confirm () {
read -p "$1 [y/n] " -n 1 -r
echo #
if [[ $REPLY =~ ^[Yy]$ ]]
then
return 0
fi
return 1
}
function pack {
echo $1
rm -rf ./_release/$1/
mkdir -p ./_release/$1/
cp -Rf ./$1/* ./_release/$1/
cp -f ./LICENSE.md ./_release/$1/
jq ".version |= . + \"-$cmthash\"" ./$1/_metadata > ./_release/$1/_metadata
# run build script if present
if [ -f "./_release/$1/_build.sh" ] ; then
chmod +x ./_release/$1/_build.sh
./_release/$1/_build.sh
fi
local cfg="./pak.json"
if [ -f "./_release/$1/_pak.json" ] ; then
cfg="./_release/$1/_pak.json"
fi
asset_packer -c "$cfg" "./_release/$1/" "./_release/$1.pak"
python paktify.py "./_release/$1.pak"
if [ ! -z "$_steamupload" ] ; then
# skip if set to not upload to steam
if [ -f "./$1/_no_steam" ] ; then
return
fi
# confirm upload
if ! confirm "Upload $1 to Steam?" ; then
return
fi
echo Uploading...
mkdir -p ./_release/tmp/upload
cp ./_release/$1.pak ./_release/tmp/upload/contents.pak
if [ "$1" == "StardustLib" ] ; then
cp ./_release/StardustLibPost.pak ./_release/tmp/upload/post.pak
fi
# gather info from metadata files
local md="./_release/$1/_metadata"
local title=$(jq -r '.friendlyName' $md)
local cid=$(jq -r '.steamContentId' $md)
local version=$(jq -r '.version' $md | sed "s/\\\"/''/g")
# start building the vdf
local vdf="./_release/tmp/.vdf" ; touch $vdf
# get the easy stuff out of the way
printf "\"workshopitem\"{\"appid\"\"211820\"\"publishedfileid\"\"$cid\"\"title\"\"$title\"\"contentfolder\"\"$(realpath ./_release/tmp/upload)\"" > $vdf
# add preview image if present
if [ -f "./$1/_previewimage" ] ; then printf "\"previewfile\"\"$(realpath ./$1/_previewimage)\"" >> $vdf ; fi
# handle hidden parameter
if jq -re '.hidden' $md > /dev/null ; then printf "\"visibility\"\"2\"" >> $vdf ; else printf "\"visibility\"\"0\"" >> $vdf ; fi
# description!
if [ -f "./$1/_steam_description" ] ; then
printf "\"description\"\"$(sed "s/\\\"/''/g" ./$1/_steam_description)\"" >> $vdf
else
printf "\"description\"\"$(jq -r '.description' $md | sed "s/\\\"/''/g")\"" >> $vdf
fi
# changelog
printf "\"changenote\"\"[b]$version[/b]\nCheck git releases for more info:\n" >> $vdf
printf "https://github.com/zetaPRIME/sb.StardustSuite/releases" >> $vdf
printf "\"}" >> $vdf # and cap off
# actually upload mod!
steamcmd +login $_steamuser +workshop_build_item $(realpath $vdf) +exit
echo # force newline that steamcmd doesn't print
rm -rf ./_release/tmp
fi
}
# mkdir -p ./_release/
pack StardustLibPost
pack StardustLib
pack StardustLite
#pack StardustTweaks
pack StarTech
pack StardustUI