-
Notifications
You must be signed in to change notification settings - Fork 7
/
dotnet-bump
executable file
·135 lines (125 loc) · 4.2 KB
/
dotnet-bump
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
set -e -u -x
cd "$(dirname "$0")"
function echo_version {
local name=$1
local version=$2
echo "${name}_version=$version"
version_prefix=$(echo "$version" | cut -d- -f1)
echo "${name}_version_prefix=$version_prefix"
version_suffix=$(echo "$version" | cut -d- -f2- -s)
echo "${name}_version_suffix=$version_suffix"
major_version=$(echo "$version_prefix" | cut -d. -f1)
echo "${name}_major_version=$major_version"
minor_version=$(echo "$version_prefix" | cut -d. -f2)
echo "${name}_minor_version=$minor_version"
if [ -n "$version_suffix" ]; then
short_date=$(echo "$version_suffix" | cut -d- -f2)
if [ "$short_date" == "$version_suffix" ]; then
short_date=$(echo "$version_suffix" | rev | cut -d. -f2 | rev)
revision=$(echo "$version_suffix" | rev | cut -d. -f1 | rev)
else
revision=$(echo "$version_suffix" | cut -d- -f3)
fi
yy=$((short_date / 1000))
mm=$(((short_date - 1000 * yy) / 50))
dd=$((short_date - 1000 * yy - 50 * mm))
echo -n "${name}_build_id="
printf "20%02d%02d%02d.%s\n" "$yy" "$mm" "$dd" "$revision"
else
echo "${name}_build_id="
fi
}
function echo_property {
local name=$1
local path=$2
local property=$3
value=$(xmllint --xpath "/Project/PropertyGroup/${property}/text()" "$path")
# shellcheck disable=SC2016
if [ "${value:0:2}" = '$(' ] && [ "${value:${#value}-1}" = ')' ]; then
echo_property "$name" "$path" "${value:2:-1}"
else
echo "$name=$value"
fi
}
platform=9.0.1xx
while [ $# -gt 0 ]; do
case "$1" in
--platform)
shift
platform=$1
;;
*)
break
;;
esac
shift
done
if [ $# -gt 0 ]; then
sdk_version=$1
shift
fi
git submodule update --init --recursive
cd sdk
if [[ -z ${sdk_version+x} ]]; then
url=https://aka.ms/dotnet/$platform/daily/productCommit-linux-x64.txt
else
url=https://dotnetbuilds.azureedge.net/public/Sdk/$sdk_version/productCommit-linux-x64.txt
fi
manifest=$(curl -L "$url")
# installer:e0c95ad21e5eac311e454c65335008161b3e4763, 7.0.103
# installer_commit="c8d103ed3c46cca9bb78098da723037e2be73bce" installer_version="8.0.100-alpha.1.23061.8"
if [[ "$manifest" =~ sdk:([0-9a-f]+),\ ([^[:space:]]+) ]] ||
[[ "$manifest" =~ sdk_commit=\"([0-9a-f]+)\"\ sdk_version=\"([^\"]+)\" ]]; then
sdk_sha=${BASH_REMATCH[1]}
sdk_version=${BASH_REMATCH[2]}
git fetch --tags
git checkout --force "$sdk_sha"
else
git fetch --tags
git checkout --force "v$sdk_version"
fi
repos=(
runtime:sdk:Microsoft.NETCore.App.Ref:true
msbuild:sdk:Microsoft.Build:true
roslyn:sdk:Microsoft.Net.Compilers.Toolset:true
#sdk:sdk:Microsoft.NET.Sdk:true
aspnetcore:sdk:Microsoft.AspNetCore.App.Ref:true
aspnetcore_internal:sdk:Microsoft.AspNetCore.App.Ref.Internal:false
templating:sdk:Microsoft.TemplateEngine.Abstractions:true
)
cd ..
echo_version sdk "$sdk_version" >dotnet-versions
git add sdk
for repo in "${repos[@]}"; do
IFS=: read -r -a path_name <<<"$repo"
xpath="string(/Dependencies/ProductDependencies/Dependency[@Name=\"${path_name[2]}\"]/@Version)"
version=$(xmllint --xpath "$xpath" "${path_name[1]}"/eng/Version.Details.xml)
if "${path_name[3]}"; then
cd "${path_name[0]}"
git fetch --tags
xpath="/Dependencies/ProductDependencies/Dependency[@Name=\"${path_name[2]}\"]/Sha/text()"
sha=$(xmllint --xpath "$xpath" ../"${path_name[1]}"/eng/Version.Details.xml)
git checkout --force "$sha"
cd ..
git add "${path_name[0]}"
fi
echo_version "${path_name[0]}" "$version" >>dotnet-versions
done
{
echo_property \
aspnetcore_transport_version \
aspnetcore/eng/Versions.props \
MicrosoftNETCoreBrowserDebugHostTransportVersion
echo_property \
aspnetcore_runtime_version \
aspnetcore/eng/Versions.props \
MicrosoftNETCoreAppRuntimeVersion
echo_property \
runtime_version_label \
runtime/eng/Versions.props \
PreReleaseVersionLabel
} >>dotnet-versions
git add dotnet-versions
git commit --allow-empty --message="v$sdk_version" --signoff
git tag "v$sdk_version"