From 53066bf5afd406b4a4623c7c429fd3cb96c6ffeb Mon Sep 17 00:00:00 2001 From: Vijay Janapa Reddi Date: Mon, 16 Feb 2026 12:43:09 -0500 Subject: [PATCH] feat(site): add version badge to navbar with auto-update on release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .github/workflows/tinytorch-publish-live.yml | 20 ++++++++++++++-- tinytorch/site/_static/custom.css | 24 ++++++++++++++++++++ tinytorch/site/_static/wip-banner.js | 6 +++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tinytorch-publish-live.yml b/.github/workflows/tinytorch-publish-live.yml index 342e73ba7..1babb81e6 100644 --- a/.github/workflows/tinytorch-publish-live.yml +++ b/.github/workflows/tinytorch-publish-live.yml @@ -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 diff --git a/tinytorch/site/_static/custom.css b/tinytorch/site/_static/custom.css index 910d4aa40..a11446911 100644 --- a/tinytorch/site/_static/custom.css +++ b/tinytorch/site/_static/custom.css @@ -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; } diff --git a/tinytorch/site/_static/wip-banner.js b/tinytorch/site/_static/wip-banner.js index caf334c2f..8f62c363a 100644 --- a/tinytorch/site/_static/wip-banner.js +++ b/tinytorch/site/_static/wip-banner.js @@ -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๐Ÿ”ฅTorch Under Construction + v${TINYTORCH_VERSION} ยท ${TINYTORCH_RELEASE_DATE}