-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish
executable file
·60 lines (46 loc) · 1.41 KB
/
publish
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
#!/bin/bash -eu
announce () {
echo ''
echo "$1"
echo '============================================================'
}
apt_ensure () {
if ! [ -x "$(command -v "$1")" ]; then
announce "Install $2"
sudo apt update
sudo apt install "$2" -y
fi
}
git_describe () {
tags=$(git tag -l)
if [ -z "$tags" ]; then
echo '0.0.0'
return
fi
tag=$(git describe --abbrev=0)
echo "${tag:1}"
}
script=$(readlink -f "${BASH_SOURCE[0]}")
directory=$(dirname "$script")
cd "$directory"
apt_ensure 'git' 'git'
apt_ensure 'dotnet' 'dotnet-sdk-8.0'
export DOTNET_CLI_TELEMETRY_OPTOUT='1'
solution='src/Chunkyard.sln'
csproj='src/Chunkyard/Chunkyard.csproj'
artifacts='artifacts'
version=$(git_describe)
runtimes=('linux-x64' 'win-x64')
announce 'Cleanup'
git clean -dfX
announce 'Build'
dotnet format "$solution" --verify-no-changes
dotnet build "$solution" -warnaserror --tl:auto
announce 'Test'
dotnet test "$solution" --no-build
for runtime in "${runtimes[@]}"; do
announce "Publish $version ($runtime)"
dotnet publish "$csproj" -o "$artifacts" -p:Version="$version" -p:ContinuousIntegrationBuild=true --tl:auto -r "$runtime" --self-contained -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=embedded
done
announce "Publish $version (dotnet tools)"
dotnet pack "$csproj" -o "$artifacts" -p:Version="$version" -p:ContinuousIntegrationBuild=true --tl:auto