-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpublish.sh
executable file
·51 lines (40 loc) · 1.42 KB
/
publish.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
#!/usr/bin/env bash
EXIT_SUCCESS=0
EXIT_ERR_NO_SOURCE=1
EXIT_ERR_SOURCE_PERMS=2
EXIT_ERR_NO_NUGET_KEY=3
EXIT_ERR_BAD_DIR=4
EXIT_ERR_ABORT=5
EXIT_ERR_BUILD=6
EXIT_ERR_GIT=7
function load_nuget_env()
{
[ ! -f ~/.ivvy_nuget.source ] && echo "Could not find source file ~/.ivvy_nuget.source" && exit $EXIT_ERR_NO_SOURCE
local octal_access=`stat -c '%a' ~/.ivvy_nuget.source`
[ ! $octal_access == "400" ] && echo "Source file ~/.ivvy_nuget.source should have 400 permissions" && exit $EXIT_ERR_SOURCE_PERMS
source ~/.ivvy_nuget.source
}
function check_nuget_env()
{
[ -z "$IVVY_NUGET_KEY" ] && echo "iVvy nuget key is required" && exit $EXIT_ERR_NO_NUGET_KEY
}
function get_package_version()
{
echo `grep -oPm1 "(?<=<VersionPrefix>)[^<]+" src/Ivvy.Subscriptions.csproj`
}
[ ! -f src/Ivvy.Subscriptions.csproj ] && echo "Script must be run from project root" && exit $EXIT_ERR_BAD_DIR
git checkout main && git pull
[[ $? != 0 ]] && exit $EXIT_ERR_GIT
load_nuget_env
check_nuget_env
package_version=$(get_package_version)
read -p "Confirm publish version $package_version (yes|no)? " accept
[[ $accept != "yes" ]] && echo "Aborted" && exit $EXIT_ERR_ABORT
dotnet pack -c Release
[[ $? != 0 ]] && exit $EXIT_ERR_BUILD
dotnet nuget push \
"src/bin/Release/Ivvy.Subscriptions.$package_version.nupkg" \
-k $IVVY_NUGET_KEY \
-s https://api.nuget.org/v3/index.json
[[ $? != 0 ]] && exit $EXIT_ERR_BUILD
exit $EXIT_SUCCESS