-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·56 lines (46 loc) · 1.36 KB
/
build.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
#!/bin/bash
set -x
SOLUTION_NAME=Naive.sln
BUILDINFO_FILE="NaiveSocksCliShared/BuildInfo.cs"
MSBUILD=msbuild
function action_pre-build() {
BUILD_TIME=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
SHORT_COMMIT=$(git log --format=%h -1)
if [[ $TRAVIS ]]; then
buildText="git $TRAVIS_BRANCH $SHORT_COMMIT"
[[ $BUILD_TIME ]] && buildText+=" built at $BUILD_TIME"
sed -i "s/BuildText = \".*\";/BuildText = \"$buildText\";/" "$BUILDINFO_FILE"
elif [[ $APPVEYOR ]]; then
buildText="git"
[[ $APPVEYOR_REPO_TAG == true ]] && buildText+=" $APPVEYOR_REPO_TAG_NAME" || buildText+=" $APPVEYOR_REPO_BRANCH"
buildText+=" $SHORT_COMMIT $APPVEYOR_BUILD_VERSION"
[[ $BUILD_TIME ]] && buildText+=" built at $BUILD_TIME"
sed -i "s/BuildText = \".*\";/BuildText = \"$buildText\";/" "$BUILDINFO_FILE"
MSBUILD=MSBuild.exe
fi
nuget restore "$SOLUTION_NAME" || return 1
dotnet restore || return 1
}
function action_msbuild() {
$MSBUILD /m "$SOLUTION_NAME" '/p:Configuration=Release' || return 1
}
function action_build() {
action_pre-build
action_msbuild
}
function action_deploy() {
pushd NaiveSocks/NaiveSocks/
bash build_deploy.sh -u ../../bin/upload || return 1
popd
pushd NaiveSocksDotNetCore/
bash build_deploy.sh -u ../bin/upload || return 1
popd
}
function action_all() {
action_build || return 1
action_deploy || return 1
}
for var in "$@"
do
"action_$var" || exit 1
done