-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·80 lines (68 loc) · 2.35 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
#!/bin/bash
# MetaphysicsIndustries.Solus
# Copyright (C) 2006-2022 Metaphysics Industries, Inc., Richard Sartor
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
PACKAGE_BASE=MetaphysicsIndustries.Solus
TAG="$1"
if [ "$TAG" = "" ]
then
TAG=$TRAVIS_TAG
fi
if [ "$TAG" = "" ]
then
echo 'No tag given. Package will not be created.'
exit 1
fi
VERSION=`echo "$TAG" | perl -ne 'print /^v(\d+\.\d+(?:\.\d+(?:\.\d+)?)?)$/'`
if [ "$VERSION" = "" ];
then
echo 'Wrong version format. Package will not be created.'
exit 1
fi
AVERSION=`grep AssemblyVersion Properties/AssemblyInfo.cs | perl -npe 's/^.*?\"//;s/\".*$//'`
if [ "$VERSION" != "$AVERSION" ]
then
echo "Tag doesn't match assembly version ($VERSION != $AVERSION). Package will not be created."
exit 1
fi
DVERSION=`echo "$VERSION" | perl -ne 'print /^(\d+\.\d+\.\d+(?:\.\d+)?)/'`
if [ "$DVERSION" = "" ];
then
DVERSION="${VERSION}.0"
echo "Adjusting version to '$DVERSION'."
else
DVERSION="$VERSION"
fi
echo 'Creating the nuget package...'
if ! dotnet pack --include-source --include-symbols -o ./ $PACKAGE_BASE.csproj /p:PackageVersion=$VERSION ; then
echo 'Error creating the package. The package will not be uploaded.'
exit 1
fi
if [ -z "$NUGET_API_KEY" ]; then
echo 'No Api Key provided. The package will not be uploaded. Please set the $NUGET_API_KEY variable.'
exit 1
fi
if [ -n "$DRY_RUN" ]; then
echo 'This is a dry run. The package will not be uploaded.'
else
echo 'Uploading the package to nuget...'
if ! nuget push $PACKAGE_BASE.$DVERSION.nupkg -Source nuget.org -ApiKey $NUGET_API_KEY ; then
echo 'Error uploading the package. Quitting.'
exit 1
fi
fi
echo 'Done.'