-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
177 lines (157 loc) · 6.48 KB
/
Copy pathbuild.sh
File metadata and controls
177 lines (157 loc) · 6.48 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
# Usage: ./build.sh [--version 0.2.0.0] [--platform x64] [--config Release] [--skip-sign] [--debug-only] [--msi]
VERSION="0.2.0.0"
PLATFORM="x64"
CONFIG="Release"
SKIP_SIGN=false
DEBUG_ONLY=false
BUILD_MSI=false
ROOT="$(cd "$(dirname "$0")" && pwd -W)"
PROJ="$ROOT\\Buzzr\\Buzzr.csproj"
OUT="$ROOT\\release"
CC="E:/Programs/msys64/ucrt64/bin/gcc.exe"
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
while [[ $# -gt 0 ]]; do
case $1 in
--version) VERSION="$2"; shift 2;;
--platform) PLATFORM="$2"; shift 2;;
--config) CONFIG="$2"; shift 2;;
--skip-sign) SKIP_SIGN=true; shift;;
--debug-only) DEBUG_ONLY=true; shift;;
--msi) BUILD_MSI=true; shift;;
*) echo "Unknown: $1"; exit 1;;
esac
done
step() { echo -e "\n\033[36m>> $1\033[0m"; }
ok() { echo -e " \033[32m$1\033[0m"; }
warn() { echo -e " \033[33m$1\033[0m"; }
fail() { echo -e " \033[31m$1\033[0m"; exit 1; }
UROOT="$(cd "$(dirname "$0")" && pwd)"
step "Building Buzzr sidecar"
cd "$UROOT/sidecar" || fail "sidecar dir not found"
CC="$CC" CGO_ENABLED=1 go build -tags goolm -ldflags "-s -w" -o buzzr-sidecar.exe . || fail "Sidecar build failed"
SIZE=$(du -h buzzr-sidecar.exe | cut -f1)
ok "Built buzzr-sidecar.exe ($SIZE)"
step "Building native taskbar badge DLL"
cd "$UROOT/Buzzr/Native" || fail "Native dir not found"
"$CC" -shared -O2 -o taskbar_badge.dll taskbar_badge.c -lole32 -luuid -lgdi32 -luser32 -lm || fail "Native DLL build failed"
SIZE=$(du -h taskbar_badge.dll | cut -f1)
ok "Built taskbar_badge.dll ($SIZE)"
if $DEBUG_ONLY; then
step "Building debug app"
cd "$UROOT"
dotnet build "$PROJ" -p:Platform=$PLATFORM -c Debug || fail "Build failed"
cp "$UROOT/sidecar/buzzr-sidecar.exe" "$UROOT/Buzzr/bin/$PLATFORM/Debug/net8.0-windows10.0.22621.0/"
ok "Debug build ready at Buzzr/bin/$PLATFORM/Debug/net8.0-windows10.0.22621.0/Buzzr.exe"
exit 0
fi
step "Preparing release directory"
rm -rf "$UROOT/release"
mkdir -p "$UROOT/release"
step "Building portable ($PLATFORM $CONFIG)"
PORTDIR="$OUT\\portable"
cd "$UROOT"
dotnet publish "$PROJ" \
--configuration "$CONFIG" \
--runtime "win-$PLATFORM" \
--self-contained true \
--output "$PORTDIR" \
-p:Platform=$PLATFORM \
-p:WindowsPackageType=None \
-p:PublishSingleFile=false \
-p:Version=$VERSION \
|| fail "Portable build failed"
ZIP="$UROOT/release/Buzzr-$VERSION-$PLATFORM-portable.zip"
cd "$UROOT/release/portable"
unset MSYS_NO_PATHCONV
zip -r "$ZIP" . > /dev/null 2>&1 || 7z a -tzip "$ZIP" . > /dev/null 2>&1 || warn "Couldn't create zip"
export MSYS_NO_PATHCONV=1
ok "Portable: $ZIP"
step "Building MSIX ($PLATFORM $CONFIG)"
cd "$UROOT"
dotnet publish "$PROJ" \
--configuration "$CONFIG" \
--runtime "win-$PLATFORM" \
--self-contained true \
--output "$OUT\\msix-publish" \
-p:Platform=$PLATFORM \
-p:WindowsPackageType=MSIX \
-p:AppxPackageDir="$OUT\\msix\\" \
-p:AppxBundle=Never \
-p:AppxPackageSigningEnabled=false \
-p:GenerateAppxPackageOnBuild=true \
-p:Version=$VERSION \
2>&1
MSIX=$(find "$UROOT/release" -name "*.msix" 2>/dev/null | head -1)
if [ -n "$MSIX" ]; then
ok "MSIX: $MSIX"
if ! $SKIP_SIGN; then
step "Signing MSIX"
CERTPATH="$ROOT\\.certs\\Buzzr.pfx"
CERTPW="Buzzr-Dev"
CERTSUBJECT="CN=dev.highest.buzzr"
if [ ! -f "$UROOT/.certs/Buzzr.pfx" ]; then
mkdir -p "$UROOT/.certs"
powershell -c "
\$cert = New-SelfSignedCertificate -Type Custom -Subject '$CERTSUBJECT' -KeyUsage DigitalSignature -FriendlyName 'Buzzr Development' -CertStoreLocation 'Cert:\CurrentUser\My' -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3','2.5.29.19={text}')
\$pw = ConvertTo-SecureString -String '$CERTPW' -Force -AsPlainText
Export-PfxCertificate -Cert \"Cert:\CurrentUser\My\\\$(\$cert.Thumbprint)\" -FilePath '$CERTPATH' -Password \$pw | Out-Null
try {
\$pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2('$CERTPATH', '$CERTPW')
\$store = New-Object System.Security.Cryptography.X509Certificates.X509Store('TrustedPeople','LocalMachine')
\$store.Open('ReadWrite'); \$store.Add(\$pfx); \$store.Close()
} catch {}
" 2>&1
ok "Created signing cert"
fi
SIGNTOOL=$(find "$USERPROFILE/.nuget/packages/microsoft.windows.sdk.buildtools" -path "*/x64/signtool.exe" 2>/dev/null | sort -r | head -1)
if [ -z "$SIGNTOOL" ]; then
SIGNTOOL=$(find "/c/Program Files" "/c/Program Files (x86)" -name "signtool.exe" -path "*/x64/*" 2>/dev/null | sort -r | head -1)
fi
if [ -n "$SIGNTOOL" ]; then
"$SIGNTOOL" sign /fd SHA256 /a /f "$ROOT\\.certs\\Buzzr.pfx" /p "$CERTPW" "$MSIX" 2>&1
if [ $? -eq 0 ]; then
ok "Signed"
FINAL="$UROOT/release/Buzzr-$VERSION-$PLATFORM.msix"
cp "$MSIX" "$FINAL"
ok "Output: $FINAL"
else
warn "Signing failed"
fi
else
warn "signtool.exe not found, MSIX is unsigned"
fi
fi
else
warn "MSIX not found in output"
fi
if [ -n "$MSIX" ] && [ -f "$UROOT/.certs/Buzzr.pfx" ]; then
step "Creating MSIX installer bundle"
BUNDLE="$UROOT/release/Buzzr-$VERSION-$PLATFORM-installer"
mkdir -p "$BUNDLE"
cp "$UROOT/release/Buzzr-$VERSION-$PLATFORM.msix" "$BUNDLE/" 2>/dev/null || cp "$MSIX" "$BUNDLE/Buzzr-$VERSION-$PLATFORM.msix"
cp "$UROOT/.certs/Buzzr.pfx" "$BUNDLE/"
cp "$UROOT/install.ps1" "$BUNDLE/"
BUNDLEZIP="$UROOT/release/Buzzr-$VERSION-$PLATFORM-installer.zip"
cd "$BUNDLE"
unset MSYS_NO_PATHCONV
zip -r "$BUNDLEZIP" . > /dev/null 2>&1 || 7z a -tzip "$BUNDLEZIP" . > /dev/null 2>&1
export MSYS_NO_PATHCONV=1
rm -rf "$BUNDLE"
ok "Installer: $BUNDLEZIP"
fi
if $BUILD_MSI; then
step "Building MSI installer"
powershell -ExecutionPolicy Bypass -File "$UROOT/build-msi.ps1" \
-Version "$VERSION" -Platform "$PLATFORM" -SourceDir "$UROOT/release/portable" -SkipBuild
if [ $? -eq 0 ]; then
ok "MSI: $UROOT/release/Buzzr-$VERSION-$PLATFORM.msi"
else
warn "MSI build failed. Make sure WiX is installed: dotnet tool install --global wix"
fi
fi
step "Done"
echo ""
find "$UROOT/release" -maxdepth 1 -type f -exec ls -lh {} \; 2>/dev/null | awk '{print " " $5 " " $9}'
echo -e "\n\033[36mOutput: $UROOT/release\033[0m"