Skip to content

Commit 18ee3d9

Browse files
Added automated build script
1 parent 7a6aa9f commit 18ee3d9

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

build.sh

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
export USE_FULL_NUMERIC_PROVIDER=true
5+
6+
7+
echo "Pulling the latest repository changes"
8+
git pull
9+
10+
11+
echo "Checking out main branch"
12+
git checkout main
13+
14+
15+
echo "Obtaining release version"
16+
VERSION=$(grep "<Version>" Directory.Build.props | sed -E 's/.*<Version>(.*)<\/Version>.*/\1/')
17+
18+
if [ -z "$VERSION" ]; then
19+
echo "Could not find <Version> in Directory.Build.props. Exiting..."
20+
exit 1
21+
fi
22+
23+
echo "Detected release version: $VERSION"
24+
25+
26+
echo "Checking out release branch"
27+
git checkout release
28+
29+
30+
echo "Merging main branch into release branch"
31+
git merge main
32+
33+
34+
echo "Pushing release branch to origin"
35+
git push origin release
36+
37+
38+
echo "Building and testing .NET solution"
39+
dotnet build --configuration Release
40+
dotnet test --configuration Release
41+
42+
43+
echo "Creating new tag with version: $VERSION"
44+
git tag "$VERSION"
45+
git push origin "$VERSION"
46+
47+
48+
echo "Pushing packages to GitHub package registry"
49+
dotnet nuget push "OnixLabs.Core/bin/Release/OnixLabs.Core.$VERSION.nupkg" --source "github"
50+
dotnet nuget push "OnixLabs.DependencyInjection/bin/Release/OnixLabs.DependencyInjection.$VERSION.nupkg" --source "github"
51+
dotnet nuget push "OnixLabs.Numerics/bin/Release/OnixLabs.Numerics.$VERSION.nupkg" --source "github"
52+
dotnet nuget push "OnixLabs.Security/bin/Release/OnixLabs.Security.$VERSION.nupkg" --source "github"
53+
dotnet nuget push "OnixLabs.Security.Cryptography/bin/Release/OnixLabs.Security.Cryptography.$VERSION.nupkg" --source "github"
54+
55+
56+
echo "Pushing packages to NuGet package registry"
57+
dotnet nuget push "OnixLabs.Core/bin/Release/OnixLabs.Core.$VERSION.nupkg" --source "nuget.org" --api-key "$NUGET_API_KEY"
58+
dotnet nuget push "OnixLabs.DependencyInjection/bin/Release/OnixLabs.DependencyInjection.$VERSION.nupkg" --source "nuget.org" --api-key "$NUGET_API_KEY"
59+
dotnet nuget push "OnixLabs.Numerics/bin/Release/OnixLabs.Numerics.$VERSION.nupkg" --source "nuget.org" --api-key "$NUGET_API_KEY"
60+
dotnet nuget push "OnixLabs.Security/bin/Release/OnixLabs.Security.$VERSION.nupkg" --source "nuget.org" --api-key "$NUGET_API_KEY"
61+
dotnet nuget push "OnixLabs.Security.Cryptography/bin/Release/OnixLabs.Security.Cryptography.$VERSION.nupkg" --source "nuget.org" --api-key "$NUGET_API_KEY"
62+
63+
64+
echo "Build and release process completed successfully!"

0 commit comments

Comments
 (0)