-
Notifications
You must be signed in to change notification settings - Fork 4
/
release.sh
executable file
·89 lines (72 loc) · 2.15 KB
/
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
#!/bin/bash
set -e
readonly RELEASE_VERSION=`cat REVISION`
usage()
{
echo "---------------------------------------"
echo "usage:"
echo "releash.sh -t your_token_content"
echo "---------------------------------------"
}
github_api_token=
while [ "$1" != "" ]; do
case $1 in
-t | --token ) shift
github_api_token=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
readonly BASE_PWD=$PWD
readonly SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
readonly SRC_PATH=$SCRIPT_PATH/src
readonly PROJECT_PATH=$SRC_PATH/dackup.csproj
readonly DOTNET_CORE_APP_VERSION_FOLDER=$SRC_PATH/bin/Release/netcoreapp3.1
dotnet nuget locals all --clear
rm -rf $SCRIPT_PATH/dist
mkdir $SCRIPT_PATH/dist
rm -rf $SRC_PATH/bin/Release
declare -a winOS=("win-x64")
declare -a unixOS=("osx-x64" "linux-x64")
declare -a releaseFiles=()
for rid in "${winOS[@]}"
do
distFile="$SCRIPT_PATH/dist/dackup-$rid.zip"
dotnet publish $PROJECT_PATH -c Release -p:PublishSingleFile=true -p:IncludeSymbolsInSingleFile=true -r $rid
cd $DOTNET_CORE_APP_VERSION_FOLDER/$rid/publish/
zip -r $distFile .
releaseFiles+=($distFile)
cd $BASE_PWD
done
for rid in "${unixOS[@]}"
do
distFile="$SCRIPT_PATH/dist/dackup-$rid.tar.gz"
dotnet publish $PROJECT_PATH -c Release -p:PublishSingleFile=true -p:IncludeSymbolsInSingleFile=true -r $rid
cd $DOTNET_CORE_APP_VERSION_FOLDER/$rid/publish/
tar -cvzf $distFile *
releaseFiles+=($distFile)
cd $BASE_PWD
done
for file in "${releaseFiles[@]}"
do
echo "Released successfully: $file"
done
if [ "$github_api_token" = "" ]; then
exit 0
fi
readonly owner="huobazi"
readonly repo="dackup"
readonly tag=$RELEASE_VERSION
# https://github.com/tcnksm/ghr
for file in "${releaseFiles[@]}"
do
ghr -t $github_api_token -u $owner -r $repo -n "Dackup $tag" -replace $tag $file
echo "$file upload to github successfully."
done
echo "Published successfully!"
cd $BASE_PWD