-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrelease.sh
executable file
·71 lines (57 loc) · 1.48 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
#! /bin/bash
if (( $# == 0 )); then
echo "No tag specified"
exit 1
fi
# CHECK VERSION IN GIT
tag="v$1"
tagRef="refs/tags/$tag"
remoteTag=$(git ls-remote origin "$tagRef")
if [[ "$remoteTag" != "" ]] ; then
echo "Error - Tag already exists in remote repository:"
echo "$remoteTag"
exit 1
fi
commit=$(git rev-parse HEAD)
if git show-ref "$tagRef" --verify --quiet ; then
echo "Tag already exists in local repository"
tagCommit=$(git rev-parse "$tagRef")
if [[ $commit == $tagCommit ]] ; then
echo "Commits are equal"
echo "HEAD: $commit"
echo "Fix: git tag -d $tag"
exit 1
else
echo "Error - Commits differ:"
echo "HEAD: $commit"
echo "$tag: $tagCommit"
exit 1
fi
fi
echo "No tag conflicts found for proposed version: $1"
# BUILD & PACK
set -e
echo "Preparing clean build"
rm -r Release
dotnet build -c Release -p:Version="$1"
echo "Preparing package"
cp -RT package Release
nuget pack ./Release/*.nuspec -Version "$1" -p "commit=$commit;branch=$(git branch --show-current)"
# TAG & PUSH
set +e
if (( $# == 1 )); then
read -p "Enter 'push' to upload release of $tag: " confirmation
[[ "$confirmation" == "push" ]]
upload=$?
else
[[ "$2" == "push" ]]
upload=$?
fi
if (( upload == 0 )); then
set -e
echo "Creating tag"
git tag "$tag"
git push origin "$tag"
echo "Uploading package"
nuget push "./*.$1.nupkg" -Source "https://api.nuget.org/v3/index.json"
fi