From ec94376e1f5a2da11ce0cbcbb76f080b920cc44c Mon Sep 17 00:00:00 2001 From: StroepWafel Date: Wed, 10 Jun 2026 01:25:51 +0930 Subject: [PATCH] nightly build --- .github/actions/build-extension/action.yml | 18 +++++++++++++----- .github/workflows/nightly.yml | 11 +++++++++-- docs/RELEASES.md | 7 ++++--- src/interface/pages/settings.svelte | 8 +++++++- src/utils/githubReleaseUpdate.ts | 17 +++++++++++++++-- 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/.github/actions/build-extension/action.yml b/.github/actions/build-extension/action.yml index adb6ac1a..c5368033 100644 --- a/.github/actions/build-extension/action.yml +++ b/.github/actions/build-extension/action.yml @@ -11,7 +11,7 @@ inputs: required: false default: stable build_label: - description: Optional build label for nightly display (e.g. run number). + description: Optional build label for nightly display (e.g. UTC build date). required: false default: "" release_repo: @@ -59,9 +59,17 @@ runs: - name: Package zips id: zip shell: bash + env: + UPDATE_CHANNEL: ${{ inputs.update_channel }} + BUILD_LABEL: ${{ inputs.build_label }} run: | VERSION="${{ steps.version.outputs.version }}" - (cd dist/chrome && zip -r "../betterseqtaplus-${VERSION}-chrome.zip" .) - (cd dist/firefox && zip -r "../betterseqtaplus-${VERSION}-firefox.zip" .) - echo "chrome_zip=dist/betterseqtaplus-${VERSION}-chrome.zip" >> "$GITHUB_OUTPUT" - echo "firefox_zip=dist/betterseqtaplus-${VERSION}-firefox.zip" >> "$GITHUB_OUTPUT" + if [ "$UPDATE_CHANNEL" = "nightly" ] && [ -n "$BUILD_LABEL" ]; then + BASE="betterseqtaplus-nightly-${BUILD_LABEL}" + else + BASE="betterseqtaplus-${VERSION}" + fi + (cd dist/chrome && zip -r "../${BASE}-chrome.zip" .) + (cd dist/firefox && zip -r "../${BASE}-firefox.zip" .) + echo "chrome_zip=dist/${BASE}-chrome.zip" >> "$GITHUB_OUTPUT" + echo "firefox_zip=dist/${BASE}-firefox.zip" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9da16900..5974de2c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -20,22 +20,29 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set build date + id: build_date + run: echo "date=$(date -u +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" + - name: Build extension id: build uses: ./.github/actions/build-extension with: gh_release_update_check: "true" update_channel: nightly - build_label: ${{ github.run_number }} + build_label: ${{ steps.build_date.outputs.date }} release_repo: ${{ github.repository }} - name: Ensure nightly release exists run: | + TITLE="Nightly (${{ steps.build_date.outputs.date }})" if ! gh release view "${{ env.NIGHTLY_TAG }}" 2>/dev/null; then gh release create "${{ env.NIGHTLY_TAG }}" \ --prerelease \ - --title "Nightly" \ + --title "$TITLE" \ --notes-file .github/nightly-release-notes.md + else + gh release edit "${{ env.NIGHTLY_TAG }}" --title "$TITLE" fi - name: Upload nightly assets diff --git a/docs/RELEASES.md b/docs/RELEASES.md index 3d06a2ba..1df9a097 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -71,7 +71,7 @@ Release and nightly workflows pass environment variables into Vite, which bakes | `GH_RELEASE_UPDATE_CHECK` | `true` | `true` | `false` / unset | | `UPDATE_CHANNEL` | `stable` | `nightly` | `stable` (unused) | | `GH_RELEASE_REPO` | `BetterSEQTA/BetterSEQTA-Plus` | same | same | -| `BUILD_LABEL` | empty | GitHub run number | empty | +| `BUILD_LABEL` | empty | UTC build date (`YYYY-MM-DD`) | empty | When `GH_RELEASE_UPDATE_CHECK` is not `true`, the update-checker code is tree-shaken out of the bundle. PR CI builds and local `npm run build` do **not** include the update badge. @@ -139,7 +139,8 @@ On first publish, edit the **title** and **release notes** on GitHub afterward. 1. Builds from the current `main` branch with the update detector enabled (nightly channel). 2. Uses a fixed release tag: **`nightly`** (marked as prerelease). 3. On first run: creates the `nightly` release with the text in [`.github/nightly-release-notes.md`](../.github/nightly-release-notes.md). -4. On every subsequent run: **replaces** the zip assets on the same release (`--clobber`). The release title and body are not rewritten. +4. On every run: sets the release title to **`Nightly (YYYY-MM-DD)`** (UTC build date) and **replaces** the zip assets on the same release (`--clobber`). The release body is not rewritten. +5. Packages zips as `betterseqtaplus-nightly-{date}-chrome.zip` / `-firefox.zip`. The nightly release body warns that builds are experimental and must not be uploaded to extension stores. @@ -206,7 +207,7 @@ Implementation: [`src/utils/githubReleaseUpdate.ts`](../src/utils/githubReleaseU 1. Fetches the `nightly` release. 2. Compares its `published_at` timestamp to `lastSeenNightlyPublishedAt` in extension storage. 3. On first install, records the current publish time without showing a badge. -4. Shows **“Update available — nightly #123”** (run number) when a newer nightly has been published. +4. Shows **“Update available — nightly (YYYY-MM-DD)”** when a newer nightly has been published. Checks are throttled to once every **6 hours** per browser profile (`localStorage` key `bsplus_lastGhReleaseCheck`). Recent results are cached in memory for the session. diff --git a/src/interface/pages/settings.svelte b/src/interface/pages/settings.svelte index dc26cf5a..50b64851 100644 --- a/src/interface/pages/settings.svelte +++ b/src/interface/pages/settings.svelte @@ -22,6 +22,7 @@ import { checkGithubReleaseUpdate, dismissNightlyUpdate, + getInstalledGhReleaseChannelLabel, isGhReleaseUpdateCheckEnabled, type GhReleaseUpdateInfo, } from "@/utils/githubReleaseUpdate"; @@ -33,6 +34,7 @@ let disclaimerTitle = $state("Confirm"); let disclaimerMessage = $state(""); const ghReleaseUpdateEnabled = isGhReleaseUpdateCheckEnabled(); + const ghReleaseChannelLabel = getInstalledGhReleaseChannelLabel(); let ghReleaseUpdate = $state(null); const openGhRelease = () => { @@ -172,7 +174,11 @@ {/if}

- GitHub release build — do not upload to extension stores. + {#if ghReleaseChannelLabel} + {ghReleaseChannelLabel} — do not upload to extension stores. + {:else} + GitHub release build — do not upload to extension stores. + {/if}

{/if} diff --git a/src/utils/githubReleaseUpdate.ts b/src/utils/githubReleaseUpdate.ts index 78aa1d0a..e0d3a5fe 100644 --- a/src/utils/githubReleaseUpdate.ts +++ b/src/utils/githubReleaseUpdate.ts @@ -35,6 +35,14 @@ function getBuildLabel(): string { return typeof __BUILD_LABEL__ !== "undefined" ? __BUILD_LABEL__ : ""; } +function formatNightlyLabel(buildDate: string): string { + return buildDate ? `nightly (${buildDate})` : "nightly"; +} + +function nightlyDateFromPublishedAt(publishedAt: string): string { + return publishedAt.slice(0, 10); +} + function getCurrentVersion(): string { return browser.runtime.getManifest().version; } @@ -158,8 +166,7 @@ async function checkNightlyUpdate(): Promise { } const lastSeen = settingsState.lastSeenNightlyPublishedAt; - const buildLabel = getBuildLabel(); - const label = buildLabel ? `nightly #${buildLabel}` : "nightly"; + const label = formatNightlyLabel(nightlyDateFromPublishedAt(release.published_at)); if (!lastSeen) { settingsState.lastSeenNightlyPublishedAt = release.published_at; @@ -177,6 +184,12 @@ export function isGhReleaseUpdateCheckEnabled(): boolean { return isUpdateCheckEnabled(); } +/** Label for the installed GitHub release build (e.g. `nightly (2025-06-10)`). */ +export function getInstalledGhReleaseChannelLabel(): string | null { + if (!isUpdateCheckEnabled() || getUpdateChannel() !== "nightly") return null; + return formatNightlyLabel(getBuildLabel()); +} + export async function checkGithubReleaseUpdate(): Promise { const fallback = { available: false, label: "", url: releasesBaseUrl() };