-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpack.sh
More file actions
73 lines (55 loc) · 2.13 KB
/
Copy pathpack.sh
File metadata and controls
73 lines (55 loc) · 2.13 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
#!/usr/bin/env bash
set -euox pipefail
umask 077
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT INT SIGTERM
have() { command -v "$1" >/dev/null 2>&1; }
die() { printf 'error: %s\n' "$1" >&2; exit 1; }
have curl || die "missing curl"
have dotnet || die "missing dotnet"
if [ -z "${P12_BASE64-}" ] || [ -z "${P12_BASE64// }" ]; then
die "P12_BASE64 is required for pack.sh"
fi
GHP="$TMP/gh-pick.sh"
curl -fsSL "https://raw.githubusercontent.com/Itexoft/devops/refs/heads/master/gh-pick.sh" -o "$GHP"
chmod +x "$GHP"
CCR=$("$GHP" "@master" "lib/cert-converter.sh")
SIGN=$("$GHP" "@master" "lib/sign-tool.sh")
DSP=$("$GHP" "@master" "lib/dotnet-sign-pack.sh")
CERT_INPUT="$TMP/cert.input"
printf '%s' "$P12_BASE64" >"$CERT_INPUT"
PFX="$TMP/cert.pfx"
if [ -n "${P12_PASSWORD-}" ]; then
"$CCR" "$P12_BASE64" pfx "$PFX" "--password=$P12_PASSWORD"
else
"$CCR" "$P12_BASE64" pfx "$PFX"
fi
SNK="$TMP/strongname.snk"
"$CCR" "$P12_BASE64" snk "$SNK"
SIGN_ARGS=()
if [ -n "${P12_PASSWORD-}" ]; then
SIGN_ARGS+=("--password=$P12_PASSWORD")
fi
ITEXOFT_PROJECT="$SCRIPT_DIR/src/Itexoft/Itexoft.csproj"
DOTNET_CLI_UI_LANGUAGE=en dotnet build "$ITEXOFT_PROJECT" -c Release \
"/p:SignAssembly=true" "/p:PublicSign=false" "/p:AssemblyOriginatorKeyFile=$SNK"
itexoft_dll="$(
DOTNET_CLI_UI_LANGUAGE=en dotnet msbuild "$ITEXOFT_PROJECT" -nologo -getProperty:TargetPath \
"/p:Configuration=Release" \
"/p:SignAssembly=true" "/p:PublicSign=false" "/p:AssemblyOriginatorKeyFile=$SNK"
)"
[ -n "${itexoft_dll-}" ] || die "Itexoft.dll target path is empty"
[ -f "$itexoft_dll" ] || die "Itexoft.dll not found after build: $itexoft_dll"
itexoft_dlls=("$itexoft_dll")
"$SIGN" "$CERT_INPUT" "${itexoft_dlls[@]}" ${SIGN_ARGS[@]+"${SIGN_ARGS[@]}"}
OUT_DIR="$SCRIPT_DIR/nuget"
mkdir -p "$OUT_DIR"
"$DSP" -c Release "$ITEXOFT_PROJECT" -o "$OUT_DIR" --no-build \
--cert="$P12_BASE64" \
${P12_PASSWORD:+--password="$P12_PASSWORD"}
nupkgs=()
while IFS= read -r -d '' pkg; do
nupkgs+=("$pkg")
done < <(find "$OUT_DIR" -maxdepth 1 -type f -name '*.nupkg' -print0)
[ "${#nupkgs[@]}" -gt 0 ] || die "no .nupkg produced"