-
Notifications
You must be signed in to change notification settings - Fork 33
/
pack.sh
executable file
·150 lines (121 loc) · 2.7 KB
/
pack.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash -eu
{ set +x; } 2>/dev/null
SOURCE="${BASH_SOURCE[0]}"
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
OS="Mac"
if [[ -e "/c/" ]]; then
OS="Windows"
fi
CONFIGURATION=Release
PUBLIC=""
BUILD=0
UPM=0
UNITYVERSION=2019.2
UNITYBUILD=0
while (( "$#" )); do
case "$1" in
-d|--debug)
CONFIGURATION="Debug"
;;
-r|--release)
CONFIGURATION="Release"
;;
-p|--public)
PUBLIC="-p:PublicRelease=true"
;;
-b|--build)
BUILD=1
;;
-u|--upm)
UPM=1
;;
-n|--unity)
UNITYBUILD=1
;;
-c)
shift
CONFIGURATION=$1
;;
--ispublic)
shift
if [[ x"$1" == x"1" ]]; then
PUBLIC="-p:PublicRelease=true"
fi
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
esac
shift
done
if [[ x"$UNITYBUILD" == x"1" ]]; then
CONFIGURATION="${CONFIGURATION}Unity"
fi
pushd $DIR >/dev/null 2>&1
if [[ x"$BUILD" == x"1" ]]; then
if [[ x"${APPVEYOR:-}" == x"" ]]; then
dotnet restore
fi
dotnet build --no-restore -c $CONFIGURATION $PUBLIC
fi
dotnet pack --no-build --no-restore -c $CONFIGURATION $PUBLIC
if [[ x"$UPM" == x"1" ]]; then
powershell scripts/Pack-Upm.ps1
elif [[ x"$UNITYBUILD" == x"0" ]]; then
if [[ x"$OS" == x"Windows" ]]; then
powershell scripts/Pack-Npm.ps1
else
srcdir="$DIR/build/packages"
# handle the aggregate package separately
targetdir="$DIR/build/npm"
mkdir -p $targetdir
rm -f $targetdir/*
pushd "$srcdir/com.spoiledcat.git" >/dev/null 2>&1
tgz="$(npm pack -q)"
mv -f $tgz $targetdir/$tgz
pushd "$srcdir/com.spoiledcat.git.tests" >/dev/null 2>&1
tgz="$(npm pack -q)"
mv -f $tgz $targetdir/$tgz
popd
# do the other packages
targetdir="$DIR/upm-ci~/packages"
mkdir -p $targetdir
rm -f $targetdir/*
cat >$targetdir/packages.json <<EOL
{
EOL
pushd $srcdir >/dev/null 2>&1
count=0
found=0
for j in `ls -d *`; do
# skip the aggregate package
if [[ x"$j" == x"com.spoiledcat.git" ]]; then continue; fi
if [[ x"$j" == x"com.spoiledcat.git.tests" ]]; then continue; fi
pushd $j >/dev/null 2>&1
if [[ -e package.json ]]; then
tgz="$(npm pack -q)"
mv -f $tgz $targetdir/$tgz
cp package.json $targetdir/$tgz.json
found=1
fi
popd >/dev/null 2>&1
comma=""
if [[ x"$count" == x"1" ]]; then comma=","; fi
if [[ x"$found" == x"1" ]];then
json="$(cat $targetdir/$tgz.json)"
cat >>$targetdir/packages.json <<EOL
${comma}
"${tgz}": ${json}
EOL
count=1
fi
echo "Created package $targetdir/$tgz"
done
popd >/dev/null 2>&1
cat >>$targetdir/packages.json <<EOL
}
EOL
fi
fi
popd >/dev/null 2>&1