feat(site): add version badge to navbar with auto-update on release

Display version number and release date (e.g., "v0.1.8 · Feb 7, 2026")
next to the "Under Construction" badge in the top nav bar. Version and
date are declared as top-of-file constants in wip-banner.js for easy
CI sed updates. Publish workflow now bumps 6 files instead of 5.
This commit is contained in:
Vijay Janapa Reddi
2026-02-16 12:43:09 -05:00
parent 09de699545
commit 53066bf5af
3 changed files with 48 additions and 2 deletions

View File

@@ -17,9 +17,10 @@ name: '🔥 TinyTorch · 🚀 Publish (Live)'
# └─ Run tinytorch-validate-dev.yml tests
#
# 3. update-version (if preflight passes) [SKIPPED if site_only=true]
# └─ Bump version in 5 files on dev branch:
# └─ Bump version in 6 files on dev branch:
# - pyproject.toml (single source of truth - __init__.py reads from this)
# - site/_static/version-badge.js
# - site/_static/wip-banner.js (navbar version badge)
# - site/extra/install.sh
# - site/_static/announcement.json
# - README.md
@@ -232,6 +233,21 @@ jobs:
echo "✅ version-badge.js updated"
cat tinytorch/site/_static/version-badge.js | grep "const version"
- name: 📝 Update version in navbar badge
run: |
echo "📝 Updating version in tinytorch/site/_static/wip-banner.js..."
VERSION_NUM="${{ needs.validate-inputs.outputs.new_version }}"
VERSION_NUM=${VERSION_NUM#tinytorch-v}
RELEASE_DATE=$(date +'%b %-d, %Y')
# Update the top-of-file constants (easy to find, easy to sed)
sed -i "s/const TINYTORCH_VERSION = '.*'/const TINYTORCH_VERSION = '$VERSION_NUM'/" tinytorch/site/_static/wip-banner.js
sed -i "s/const TINYTORCH_RELEASE_DATE = '.*'/const TINYTORCH_RELEASE_DATE = '$RELEASE_DATE'/" tinytorch/site/_static/wip-banner.js
echo "✅ wip-banner.js updated"
head -10 tinytorch/site/_static/wip-banner.js
- name: 📝 Update version in installer
run: |
echo "📝 Updating version in tinytorch/site/extra/install.sh..."
@@ -290,7 +306,7 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add tinytorch/pyproject.toml tinytorch/site/_static/version-badge.js tinytorch/site/extra/install.sh tinytorch/site/_static/announcement.json tinytorch/README.md
git add tinytorch/pyproject.toml tinytorch/site/_static/version-badge.js tinytorch/site/_static/wip-banner.js tinytorch/site/extra/install.sh tinytorch/site/_static/announcement.json tinytorch/README.md
git commit -m "chore(tinytorch): bump version to ${{ needs.validate-inputs.outputs.new_version }}" || echo "No changes to commit"
git push origin dev

View File

@@ -410,6 +410,26 @@ pre.mermaid {
letter-spacing: 0.02em;
}
.tinytorch-bar-version {
font-size: 0.75rem;
font-weight: 500;
color: #9ca3af;
background: rgba(156, 163, 175, 0.1);
padding: 0.3rem 0.75rem;
border-radius: 4px;
border: 1px solid rgba(156, 163, 175, 0.2);
text-decoration: none;
font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
letter-spacing: 0.01em;
transition: all 0.15s ease;
}
.tinytorch-bar-version:hover {
color: #e5e7eb;
background: rgba(156, 163, 175, 0.18);
border-color: rgba(156, 163, 175, 0.35);
}
.tinytorch-bar-links {
display: flex;
align-items: center;
@@ -483,6 +503,10 @@ pre.mermaid {
display: none;
}
.tinytorch-bar-version {
display: none;
}
.tinytorch-bar-left {
gap: 0.5rem;
}

View File

@@ -3,6 +3,11 @@
* Elegant navigation bar matching MLSysBook style
*/
// ── Release info (auto-updated by CI on publish) ──────────────
const TINYTORCH_VERSION = '0.1.8';
const TINYTORCH_RELEASE_DATE = 'Feb 7, 2026';
// ───────────────────────────────────────────────────────────────
document.addEventListener('DOMContentLoaded', function() {
// Only inject if not already present
if (document.getElementById('tinytorch-bar')) return;
@@ -28,6 +33,7 @@ document.addEventListener('DOMContentLoaded', function() {
Tiny<span class="brand-fire">🔥</span>Torch
</a>
<span class="tinytorch-bar-badge">Under Construction</span>
<a href="https://github.com/harvard-edge/cs249r_book/releases" target="_blank" rel="noopener noreferrer" class="tinytorch-bar-version" title="View releases on GitHub">v${TINYTORCH_VERSION} · ${TINYTORCH_RELEASE_DATE}</a>
</div>
<div class="tinytorch-bar-links">
<a href="${siteRoot}_static/downloads/TinyTorch-Guide.pdf" class="download-link" title="Download Course Guide (PDF)">