-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease
More file actions
executable file
·120 lines (102 loc) · 3.61 KB
/
Copy pathrelease
File metadata and controls
executable file
·120 lines (102 loc) · 3.61 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
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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
source "${SCRIPT_DIR}/scripts/common"
usage() {
cat <<'USAGE'
Usage: ./release [options]
Options:
-o, --artifacts <dir> Package output directory. Default: artifacts.
--artifact-location <dir> Alias for --artifacts.
-c, --configuration <Debug|Release> Build configuration. Default: Release.
--version-suffix <suffix> Optional prerelease version suffix.
--build-number <number> Optional build number, padded to five digits.
-h, --help Show this help text.
USAGE
}
artifact_location="artifacts"
configuration="Release"
version_suffix=""
build_number=""
while (($#)); do
case "$1" in
-o|--artifacts|--artifact-location)
option="$1"
shift
linvast_require_value "$option" "${1-}"
artifact_location="$1"
;;
-c|--configuration)
shift
linvast_require_value "--configuration" "${1-}"
configuration="$1"
;;
--version-suffix)
shift
linvast_require_value "--version-suffix" "${1-}"
version_suffix="$1"
;;
--build-number)
shift
linvast_require_value "--build-number" "${1-}"
build_number="$1"
;;
-h|--help)
usage
exit 0
;;
*)
linvast_die "unknown option '$1'"
;;
esac
shift
done
linvast_validate_configuration "$configuration"
build_number_string=""
prerelease_version=""
if [[ -n "$build_number" ]]; then
if [[ -z "$version_suffix" ]]; then
linvast_die "--build-number requires --version-suffix"
fi
if build_number_string="$(linvast_format_build_number "$build_number")"; then
:
else
build_number_string=""
fi
fi
if [[ -n "$version_suffix" ]]; then
prerelease_version="$(linvast_prerelease_version "$version_suffix" "$build_number_string")"
fi
artifact_dir="$(linvast_resolve_path "$artifact_location")"
if [[ -z "$artifact_dir" || "$artifact_dir" == "/" ]]; then
linvast_die "refusing to use '${artifact_dir:-<empty>}' as an artifact directory"
fi
cd "$LINVAST_REPO_ROOT"
linvast_prepare_nuget_config
trap linvast_restore_nuget_config EXIT
if [[ -n "$version_suffix" && -n "$build_number_string" ]]; then
printf 'Building prerelease packages with version "%s"\n' "$prerelease_version"
elif [[ -n "$version_suffix" ]]; then
printf 'Building prerelease packages with version "%s"\n' "$prerelease_version"
else
printf 'Building production packages\n'
fi
printf 'Artifacts will be placed in: %s\n' "$artifact_dir"
rm -rf "$artifact_dir"
mkdir -p "$artifact_dir"
dotnet clean "$LINVAST_SOLUTION" -v minimal -c "$configuration" -m:1
dotnet restore "$LINVAST_SOLUTION" -v minimal -m:1
build_args=(dotnet build "$LINVAST_SOLUTION" -v minimal -c "$configuration" --no-restore -m:1)
pack_args=(dotnet pack "$LINVAST_SOLUTION" -v minimal -c "$configuration" --no-build -m:1 -o "$artifact_dir")
if [[ -n "$version_suffix" ]]; then
build_args+=(--version-suffix "$version_suffix" -p:Version="$prerelease_version" -p:PackageVersion="$prerelease_version")
pack_args+=(--version-suffix "$version_suffix" -p:Version="$prerelease_version" -p:PackageVersion="$prerelease_version")
else
pack_args+=(--include-symbols)
fi
if [[ -n "$build_number_string" ]]; then
build_args+=(-p:BuildNumber="$build_number_string")
pack_args+=(-p:BuildNumber="$build_number_string")
fi
"${build_args[@]}"
"${pack_args[@]}"