-
Notifications
You must be signed in to change notification settings - Fork 497
Expand file tree
/
Copy pathprepare_release.sh
More file actions
executable file
·84 lines (73 loc) · 2.48 KB
/
prepare_release.sh
File metadata and controls
executable file
·84 lines (73 loc) · 2.48 KB
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
#!/bin/bash -e
is_minor="$1" # type is "minor" or "patch"
is_patch="$2" # type is "minor" or "patch"
echo "is_minor: $is_minor"
echo "is_patch: $is_patch"
if [ "$is_minor" = true ] && [ "$is_patch" = true ]; then
echo "Only one of minor version and patch version should be specified."
exit 1
elif [ "$is_minor" = true ] && [ "$is_patch" = false ]; then
type="minor"
echo "decided to update minor version"
elif [ "$is_minor" = false ] && [ "$is_patch" = true ]; then
type="patch"
echo "decided to update patch version"
else
echo "At least one of minor version and patch version should be specified."
exit 1
fi
mkdir ./temp;
mkdir ./temp/runtimes;
cp ./LLama/runtimes ./temp -R;
cp ./LLama/runtimes/build/*.* ./temp/;
# get the current version
cd temp;
dotnet add package LLamaSharp;
version=$(dotnet list temp.csproj package | grep LLamaSharp);
# TODO: This didn´t work on osx...we need a solution
read -ra arr <<< "$version"
version="${arr[-1]}"
echo "The latest version: $version";
# update the version
if [[ $type == "minor" ]]; then
regex="[0-9]+\.([0-9]+)\.[0-9]+$"
if [[ $version =~ $regex ]]; then
b="${BASH_REMATCH[1]}"
b=$((b + 1))
updated_version="${version%%.*}.$b.0"
echo "Updated version: $updated_version"
else
echo "Invalid version format"
exit 1
fi
elif [[ $type == "patch" ]]; then
regex="([0-9]+)$"
if [[ $version =~ $regex ]]; then
c="${BASH_REMATCH[1]}"
c=$((c + 1))
updated_version="${version%.*}.$c"
echo "Updated version: $updated_version"
else
echo "Invalid version format"
exit 1
fi
else
echo "Invalid type"
exit 1
fi
cd ..
# pack the main package
dotnet pack ./LLama/LLamaSharp.csproj -c Release -o ./temp/ /p:PackageVersion=$updated_version /p:Version=$updated_version /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg;
dotnet pack ./LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj -c Release -o ./temp/ /p:PackageVersion=$updated_version /p:Version=$updated_version /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg;
dotnet pack ./LLama.KernelMemory/LLamaSharp.KernelMemory.csproj -c Release -o ./temp/ /p:PackageVersion=$updated_version /p:Version=$updated_version /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg;
# pack the backends
cd temp
for nuspec in *.nuspec
do
echo "Packing $nuspec"
nuget pack $nuspec -version $updated_version
done
# write the version to the file
echo $updated_version > version.txt
cd ..
exit 0