Repository navigation
180 lines (145 loc) · 6.89 KB
/
Copy pathrelease.yml
File metadata and controls
180 lines (145 loc) · 6.89 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
178
179
180
name: Release
# Publishes prebuilt, self-contained binaries so a tech can install without
# git, without the .NET SDK, and without waiting for a build on the target.
#
# git tag v1.3.0 && git push origin v1.3.0
#
# Both targets are cross-published from one Linux runner - self-contained
# publish needs no native toolchain for the target OS.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version to build, without the leading v (e.g. 1.3.0)"
required: true
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Resolve version
id: ver
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF_NAME#v}"
fi
# The tag is what techs will quote when reporting a problem, so it has
# to agree with the version the service prints at startup. Catching a
# mismatch here beats shipping a release labelled differently from the
# binary inside it.
CSPROJ=$(grep -oPm1 '(?<=<Version>)[^<]+' ScaleReaderService.csproj)
if [ "$VERSION" != "$CSPROJ" ]; then
echo "::error::Tag version '$VERSION' does not match <Version>$CSPROJ</Version> in ScaleReaderService.csproj."
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Building $VERSION"
# -p:Version so the built service reports the release it shipped in. The
# csproj version was previously hand-edited to match each tag, which held
# only as long as someone remembered — Foundation's Setup > Services tab
# reads this, and a stale number there is worse than none.
- name: Publish win-x64
run: |
dotnet publish ScaleReaderService.csproj \
-c Release -r win-x64 --self-contained true \
-o out/win-x64/app -p:Version="${{ steps.ver.outputs.version }}"
- name: Publish linux-arm64
run: |
dotnet publish ScaleReaderService.csproj \
-c Release -r linux-arm64 --self-contained true \
-o out/linux-arm64/app -p:Version="${{ steps.ver.outputs.version }}"
- name: Assemble packages
env:
V: ${{ steps.ver.outputs.version }}
run: |
set -euo pipefail
# --- Windows: the installer runs straight out of the unzipped folder.
cp deploy/install-windows.ps1 deploy/INSTALL.bat deploy/package-README.txt out/win-x64/
mv out/win-x64/package-README.txt out/win-x64/README.txt
(cd out/win-x64 && zip -qr "../../scale-reader-win-x64.zip" .)
# --- Linux arm64 (Raspberry Pi 4/5): install.sh finds ./app beside it
# and skips the SDK install and the build entirely.
cp deploy/install.sh out/linux-arm64/
chmod +x out/linux-arm64/install.sh out/linux-arm64/app/ScaleReaderService
tar -czf "scale-reader-linux-arm64.tar.gz" -C out/linux-arm64 .
ls -lh scale-reader-*
- name: Smoke-test the Windows build
env:
V: ${{ steps.ver.outputs.version }}
run: |
# Confirm the packaged artefacts are actually what we think they are,
# rather than discovering it on a customer PC.
test -f "out/win-x64/app/ScaleReaderService.exe" || { echo "missing exe"; exit 1; }
test -f "out/win-x64/INSTALL.bat" || { echo "missing INSTALL.bat"; exit 1; }
test -f "out/win-x64/install-windows.ps1" || { echo "missing installer"; exit 1; }
test -f "out/linux-arm64/app/ScaleReaderService" || { echo "missing linux binary"; exit 1; }
test -f "out/linux-arm64/install.sh" || { echo "missing install.sh"; exit 1; }
# A database must never ship - it would overwrite a site's configuration.
if find out -name "*.db" -o -name "*.db-wal" -o -name "*.db-shm" | grep -q .; then
echo "::error::A database file leaked into the package."
exit 1
fi
echo "Package contents OK"
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
V: ${{ steps.ver.outputs.version }}
run: |
NOTES=$(cat <<EOF
Prebuilt, self-contained builds of the Scale Reader Service. No .NET,
no SDK and no git needed on the target machine.
## Windows
Download \`scale-reader-win-x64.zip\`, unzip it, then from an
**admin** command prompt in that folder:
\`\`\`
INSTALL.bat https://your-web-app-url
\`\`\`
Installs the service with automatic startup, keeps the existing
database, and applies the web app URL. Re-run the same command to
update. Add \`-ResetDb\` to start from a clean database.
## Raspberry Pi (64-bit, Pi 4/5)
\`\`\`
curl -fsSL -o srs.tar.gz https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/scale-reader-linux-arm64.tar.gz
mkdir -p /tmp/srs && tar -xzf srs.tar.gz -C /tmp/srs
bash /tmp/srs/install.sh https://your-web-app-url
\`\`\`
The URL must match the web app's real scheme and port - a wrong one
leaves the service reconnecting forever.
Other architectures still build from source; see the README.
## Several sites
One scale can work for several Foundation sites at once - a scale house
several companies share, for example. Give every site's URL. On Windows,
in quotes and separated by commas (unquoted, Windows splits the list at
each comma):
\`\`\`
INSTALL.bat "https://site-one.example.com,https://site-two.example.com"
\`\`\`
On a Pi, separated by spaces:
\`\`\`
bash /tmp/srs/install.sh https://site-one.example.com https://site-two.example.com
\`\`\`
Each site gets its own connection and retries. The scale is read once and
every weight goes to every connected site; a request (scale list,
Auto-Detect, setup changes) is answered to the site that asked. Set the
scale up once; then on **each** site, pick it on the Scales page.
## Pi git auth
Nothing above needs git on the target - that is the point of shipping
prebuilt. A Pi that also has to \`git clone\` or \`git pull\` a
**private** GTMichelli-Dev repo needs a one-time bootstrap first:
https://github.com/GTMichelli-Dev/pi-git-auth
EOF
)
gh release create "v$V" \
--title "v$V" \
--notes "$NOTES" \
"scale-reader-win-x64.zip" \
"scale-reader-linux-arm64.tar.gz"