From 678f950fa3ae7419e2f72f0f66a35894b81803bd Mon Sep 17 00:00:00 2001 From: Haren Daishika Date: Tue, 24 Nov 2026 19:58:11 +0530 Subject: [PATCH] Website: name the newest release and link straight to its installer The download buttons and the version reset to GitHub's releases page and old fallback versions (0.4.1, 0.4.2) until the browser heard from GitHub, which allows 60 requests an hour from one address, so visitors could see an old version and no direct installer. site.js now starts from the newest release known when the page was published, with direct links to its installer and fil archives, and GitHub's answer replaces them only with a newer release. The Windows buttons carry the direct installer link in the page itself, and Google reads 0.4.4. To keep this current, the Pages deploy writes the latest release's version into the pages it publishes, and the release workflow starts that deploy once a release is complete. --- .github/workflows/pages.yml | 24 +++++++++++++++++++++--- .github/workflows/release.yml | 13 +++++++++++++ site/assets/docs.js | 2 +- site/assets/home.js | 2 +- site/assets/site.js | 23 ++++++++++++++++++++--- site/docs/install/index.html | 2 +- site/index.html | 4 ++-- site/tools/docs/install.html | 2 +- 8 files changed, 60 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 668627c..f657a2b 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,6 +1,7 @@ -# Publishes the website in site/ to GitHub Pages. It runs only when a push to -# main changes something under site/ (or this file), and can be run by hand -# from the Actions tab. The site is plain files: nothing is built. +# Publishes the website in site/ to GitHub Pages. It runs when a push to main +# changes something under site/ (or this file), when a release is complete +# (release.yml starts it), and by hand from the Actions tab. The site is plain +# files: nothing is built, but the newest release's version is written in. # # Pages must be set to deploy from GitHub Actions: Settings › Pages › Source. name: pages @@ -32,6 +33,23 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: - uses: actions/checkout@v4 + # The pages name the newest release, and link straight to its files, + # before the visitor's browser asks GitHub. The release workflow runs + # this deploy again once a release is complete, so they never lag. + - name: Name the newest release + env: + GH_TOKEN: ${{ github.token }} + run: | + v=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q .tagName | sed 's/^v//') + if ! echo "$v" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "Latest release '$v' is not a version; the pages keep what they have." + exit 0 + fi + sed -i -E "s/const KNOWN = '[^']*'/const KNOWN = '$v'/" site/assets/site.js + sed -i -E "s/\"softwareVersion\":\"[^\"]*\"/\"softwareVersion\":\"$v\"/" site/index.html + sed -i -E "s#releases/download/v[0-9.]+/Filiation-Setup-[0-9.]+-windows-amd64\.exe#releases/download/v$v/Filiation-Setup-$v-windows-amd64.exe#g" site/index.html site/docs/install/index.html + grep -q "const KNOWN = '$v'" site/assets/site.js + echo "The pages name v$v." - uses: actions/configure-pages@v5 - uses: actions/upload-pages-artifact@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bec23ae..e46f921 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,3 +67,16 @@ jobs: $lines += "$hash $name" [IO.File]::WriteAllText("$PWD/sums/checksums.txt", ($lines -join "`n") + "`n") gh release upload $tag sums/checksums.txt --clobber + + # The website names the newest release and links to its installer; publish + # it again now the release is complete (pages.yml). + website: + needs: windows-installer + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Deploy the website + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh workflow run pages.yml --repo "$GITHUB_REPOSITORY" --ref main diff --git a/site/assets/docs.js b/site/assets/docs.js index c4bf0d7..5cdbeca 100644 --- a/site/assets/docs.js +++ b/site/assets/docs.js @@ -28,7 +28,7 @@ const cmds = $$('code[data-cmd]'); cmds.forEach((c) => { c.dataset.template = c.textContent; }); const fill = (v) => cmds.forEach((c) => { c.textContent = c.dataset.template.replace(/\{v\}/g, v); }); - fill(window.filVersion || '0.4.2'); + fill(window.filVersion); document.addEventListener('fil:version', (e) => { fill(e.detail); const os = $('[data-tabgroup="os"] [aria-selected="true"]'); diff --git a/site/assets/home.js b/site/assets/home.js index e50d621..d5d8b33 100644 --- a/site/assets/home.js +++ b/site/assets/home.js @@ -211,7 +211,7 @@ const showOS = (os) => { osNow = os; select(osTabs, osTabs.find((b) => b.dataset.os === os)); - $('#os-cmd').textContent = cmds[os](window.filVersion || '0.4.1'); + $('#os-cmd').textContent = cmds[os](window.filVersion); const dl = $('#os-download'); dl.dataset.os = os; dl.textContent = 'Download fil for ' + { windows: 'Windows', macos: 'macOS', linux: 'Linux' }[os]; diff --git a/site/assets/site.js b/site/assets/site.js index a9a72e8..bbaa513 100644 --- a/site/assets/site.js +++ b/site/assets/site.js @@ -1,6 +1,7 @@ // Shared by both pages: copy buttons, the phone menu, the star count, and // download links that point at the newest release for the visitor's system. -// Every piece works without the network: links fall back to the releases page. +// Every piece works without the network: links name the newest release the +// page knows of. (() => { const REPO = 'codevector-2003/filiation'; const RELEASES = 'https://github.com/' + REPO + '/releases/latest'; @@ -70,8 +71,24 @@ // Download links: [data-download="app|cli"], optionally with // data-os="windows|macos|linux" to pin a system instead of the visitor's. - const fallback = () => document.querySelectorAll('[data-download]').forEach((a) => { a.href = RELEASES; }); - fallback(); + // They point straight at the files of the newest release known when the + // page was published, which the deploy writes in below (pages.yml), so + // they are right before GitHub answers, and when it never does (it allows + // 60 requests an hour from one address). GitHub's answer then replaces + // them with a newer release's, if there is one. + const KNOWN = '0.4.4'; + const fileURL = (v, name) => 'https://github.com/' + REPO + '/releases/download/v' + v + '/' + name; + const known = { + cli: { windows: 'fil_' + KNOWN + '_windows_amd64.zip', macos: 'fil_' + KNOWN + '_darwin_arm64.tar.gz', linux: 'fil_' + KNOWN + '_linux_amd64.tar.gz' }, + app: { windows: 'Filiation-Setup-' + KNOWN + '-windows-amd64.exe' }, + }; + const urls = (set) => Object.fromEntries(Object.entries(set).map(([k, name]) => [k, fileURL(KNOWN, name)])); + window.filAssets = { cli: urls(known.cli), app: urls(known.app) }; + document.querySelectorAll('[data-download]').forEach((a) => { + a.href = window.filAssets[a.dataset.download][a.dataset.os || os] || RELEASES; + }); + window.filVersion = KNOWN; + document.querySelectorAll('[data-version]').forEach((el) => { el.textContent = el.dataset.version.replace('{v}', KNOWN); }); get('https://api.github.com/repos/' + REPO + '/releases/latest').then((rel) => { const version = String(rel.tag_name || '').replace(/^v/, ''); const assets = rel.assets || []; diff --git a/site/docs/install/index.html b/site/docs/install/index.html index 3ae7f5d..ef7a566 100644 --- a/site/docs/install/index.html +++ b/site/docs/install/index.html @@ -77,7 +77,7 @@

Install

The app

Download the installer and run it. It installs for you only, needs no administrator rights, and adds fil to your PATH so a terminal and your AI assistant can find it.

-

Download the Windows installer

+

Download the Windows installer

!The installer isn't signed yet, so Windows SmartScreen may warn you. Choose More info, then Run anyway.
diff --git a/site/index.html b/site/index.html index 1f4da55..e38c407 100644 --- a/site/index.html +++ b/site/index.html @@ -24,7 +24,7 @@ - + @@ -280,7 +280,7 @@

Filiation: which text was copied from which.

For everyone. Your papers, search, the map and the Reader in one window.
Windows installerUpdates itself
macOS and Linux: installers are coming; the app builds from source today. -Download for Windows +Download for Windows
The command line diff --git a/site/tools/docs/install.html b/site/tools/docs/install.html index 119d585..1b31463 100644 --- a/site/tools/docs/install.html +++ b/site/tools/docs/install.html @@ -11,7 +11,7 @@

The app

Download the installer and run it. It installs for you only, needs no administrator rights, and adds fil to your PATH so a terminal and your AI assistant can find it.

-

Download the Windows installer

+

Download the Windows installer

!The installer isn't signed yet, so Windows SmartScreen may warn you. Choose More info, then Run anyway.