-
Notifications
You must be signed in to change notification settings - Fork 0
293 lines (247 loc) · 8.46 KB
/
Copy pathnightly.yml
File metadata and controls
293 lines (247 loc) · 8.46 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Nightly Build
on:
schedule:
- cron: "0 6 * * *" # 06:00 UTC nightly
workflow_dispatch:
concurrency:
group: nightly
cancel-in-progress: true
jobs:
nightly-build:
runs-on: ubuntu-latest
outputs:
build_date: ${{ steps.capture.outputs.build_date }}
git_hash: ${{ steps.capture.outputs.git_hash }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Capture metadata
id: capture
run: |
echo "build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
echo "git_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc rpm dpkg-dev
sudo apt-get install -y libarchive-zip-perl
- name: Install Python build dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pyinstaller
- name: Install PythonTools
run: |
if [ ! -d PythonTools ]; then
git clone https://github.com/linktech-engineering-llc/PythonTools.git
fi
python3 -m pip install PythonTools/
- name: Make scripts executable
run: chmod +x packaging/*.sh
- name: Build all artifacts
run: ./packaging/build_all.sh
- name: Normalize RPM filename
run: |
OUT=packaging/output
RPM_SRC=$(find packaging/rpmbuild/RPMS/x86_64 -type f -name "*.rpm" | head -n 1)
if [[ -n "$RPM_SRC" ]]; then
ARCH=$(echo "$RPM_SRC" | sed -n 's/.*\.\(.*\)\.rpm/\1/p')
VERSION=$(basename "$RPM_SRC" | sed -n 's/RunUpdates-\(.*\)-.*\.rpm/\1/p')
mv "$RPM_SRC" "$OUT/RunUpdates_${VERSION}.${ARCH}.rpm"
fi
- name: Collect artifacts
run: |
mkdir -p artifacts
cp packaging/output/RunUpdates_* artifacts/
- name: Generate metadata.json
run: |
mkdir -p artifacts
# Detect toolchain versions
PYTHON_VERSION=$(python3 --version | awk '{print $2}')
PYINSTALLER_VERSION=$(pyinstaller --version 2>/dev/null || echo "unknown")
BUILDER_OS="ubuntu-latest"
# Start metadata.json
cat > artifacts/metadata.json <<EOF
{
"meta_version": 2,
"build": {
"date": "${{ steps.capture.outputs.build_date }}",
"commit": "${{ steps.capture.outputs.git_hash }}",
"branch": "nightly",
"workflow_run_id": $GITHUB_RUN_ID
},
"toolchain": {
"python": "$PYTHON_VERSION",
"pyinstaller": "$PYINSTALLER_VERSION",
"builder_os": "$BUILDER_OS"
},
"artifacts": [
EOF
FIRST=1
for f in artifacts/RunUpdates_*; do
NAME=$(basename "$f")
SIZE=$(stat -c%s "$f")
SHA=$(sha256sum "$f" | awk '{print $1}')
CRC=$(crc32 "$f")
# Detect type, OS, arch
case "$NAME" in
*.deb)
TYPE="deb"
OS="linux"
ARCH="amd64"
;;
*.rpm)
TYPE="rpm"
OS="linux"
ARCH="x86_64"
;;
*.zip)
TYPE="zip"
OS="windows"
ARCH="x86_64"
;;
*.tgz|*.tar.gz)
TYPE="tgz"
OS="linux"
ARCH="amd64"
;;
*)
TYPE="unknown"
OS="unknown"
ARCH="unknown"
;;
esac
if [ $FIRST -eq 0 ]; then
echo "," >> artifacts/metadata.json
fi
FIRST=0
cat >> artifacts/metadata.json <<EOF
{
"name": "$NAME",
"type": "$TYPE",
"os": "$OS",
"arch": "$ARCH",
"size": $SIZE,
"sha256": "$SHA",
"crc32": "$CRC"
}
EOF
done
# Close JSON
cat >> artifacts/metadata.json <<EOF
]
}
EOF
- name: Upload nightly artifacts
uses: actions/upload-artifact@v4
with:
name: nightly-runupdates
path: artifacts
- name: Validate metadata.json
run: |
pip install jsonschema
python3 packaging/metadata/validate.py artifacts/metadata.json
- name: Remove existing nightly assets
env:
GH_TOKEN: ${{ github.token }}
run: |
ASSETS=$(gh release view nightly --json assets --jq '.assets[].name')
for asset in $ASSETS; do
if [[ "$asset" == RunUpdates* ]]; then
echo "Deleting asset: $asset"
gh release delete-asset nightly "$asset" --yes
fi
done
- name: Upload artifacts to nightly release
uses: softprops/action-gh-release@v1
with:
tag_name: nightly
files: packaging/output/*
publish-dashboard:
runs-on: ubuntu-latest
needs: nightly-build
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Preserve existing dashboard files
run: |
mkdir -p dashboard
cp dashboard.js dashboard.js.bak 2>/dev/null || true
- name: Download nightly artifacts
uses: actions/download-artifact@v4
with:
name: nightly-runupdates
path: artifacts
- name: Copy metadata.json to dashboard root
run: |
cp artifacts/metadata.json .
- name: Generate dashboard HTML
run: |
META=artifacts/metadata.json
RELEASE_URL="https://github.com/Linktech-Engineering-LLC/RunUpdates/releases/download/nightly"
mkdir -p dashboard
rm -f dashboard/*
curl -s -o dashboard/qr.png \
"https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https://linktech-engineering-llc.github.io/RunUpdates/"
cat > dashboard/index.html <<EOF
<html>
<head>
<title>RunUpdates Nightly Dashboard</title>
<style>
body { font-family: Arial; margin: 20px; }
table { border-collapse: collapse; margin-top: 10px; width: 100%; }
th, td { padding: 8px 12px; border: 1px solid #ccc; }
th { background: #f0f0f0; }
.badge-row img { margin-right: 8px; }
.download-btn {
background: #0078d4;
color: white;
padding: 6px 12px;
border-radius: 4px;
text-decoration: none;
}
.download-btn:hover {
background: #005a9e;
}
.qr { margin-top: 20px; }
</style>
</head>
<body>
<h1>RunUpdates Nightly Dashboard</h1>
<div class="badge-row">
<img src="https://img.shields.io/badge/version-loading-blue" id="version-badge">
<img src="https://img.shields.io/badge/date-loading-lightgrey" id="date-badge">
<img src="https://img.shields.io/badge/python-loading-yellow" id="python-badge">
<img src="https://img.shields.io/badge/pyinstaller-loading-orange" id="pyi-badge">
</div>
<h2>Build Metadata</h2>
<div id="build-info"></div>
<h2>Artifacts</h2>
<div id="artifact-table"></div>
<div class="qr">
<h2>QR Code</h2>
<img src="qr.png" alt="QR Code">
</div>
<script src="dashboard.js"></script>
</body>
</html>
- name: Restore dashboard.js
run: |
if [ -f dashboard.js.bak ]; then
mv dashboard.js.bak dashboard.js
fi
- name: Publish dashboard to gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
cp -r dashboard/* .
git add .
git commit -m "Update nightly dashboard" || echo "No changes"
git push origin gh-pages