From 4707821451d7889f577ccb42312b64f7e13913c2 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Tue, 27 Jan 2026 17:36:38 -0500 Subject: [PATCH] chore: replace patch doc links (#25591) chore: automatically use the latest patch release --- docs/static/archived-versions.json | 28 --------------------- misc/release/archive-version.js | 40 +++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/static/archived-versions.json b/docs/static/archived-versions.json index b6fbf1c759..48fc8d5513 100644 --- a/docs/static/archived-versions.json +++ b/docs/static/archived-versions.json @@ -7,34 +7,14 @@ "label": "v2.4.1", "url": "https://docs.v2.4.1.archive.immich.app" }, - { - "label": "v2.4.0", - "url": "https://docs.v2.4.0.archive.immich.app" - }, { "label": "v2.3.1", "url": "https://docs.v2.3.1.archive.immich.app" }, - { - "label": "v2.3.0", - "url": "https://docs.v2.3.0.archive.immich.app" - }, { "label": "v2.2.3", "url": "https://docs.v2.2.3.archive.immich.app" }, - { - "label": "v2.2.2", - "url": "https://docs.v2.2.2.archive.immich.app" - }, - { - "label": "v2.2.1", - "url": "https://docs.v2.2.1.archive.immich.app" - }, - { - "label": "v2.2.0", - "url": "https://docs.v2.2.0.archive.immich.app" - }, { "label": "v2.1.0", "url": "https://docs.v2.1.0.archive.immich.app" @@ -43,18 +23,10 @@ "label": "v2.0.1", "url": "https://docs.v2.0.1.archive.immich.app" }, - { - "label": "v2.0.0", - "url": "https://docs.v2.0.0.archive.immich.app" - }, { "label": "v1.144.1", "url": "https://docs.v1.144.1.archive.immich.app" }, - { - "label": "v1.144.0", - "url": "https://docs.v1.144.0.archive.immich.app" - }, { "label": "v1.143.1", "url": "https://docs.v1.143.1.archive.immich.app" diff --git a/misc/release/archive-version.js b/misc/release/archive-version.js index 1a66963dad..5c0ed9f22f 100755 --- a/misc/release/archive-version.js +++ b/misc/release/archive-version.js @@ -1,6 +1,12 @@ #! /usr/bin/env node const { readFileSync, writeFileSync } = require('node:fs'); +const asVersion = (item) => { + const { label, url } = item; + const [major, minor, patch] = label.substring(1).split('.').map(Number); + return { major, minor, patch, label, url }; +}; + const nextVersion = process.argv[2]; if (!nextVersion) { console.log('Usage: archive-version.js '); @@ -8,10 +14,32 @@ if (!nextVersion) { } const filename = './docs/static/archived-versions.json'; -const oldVersions = JSON.parse(readFileSync(filename)); -const newVersions = [ - { label: `v${nextVersion}`, url: `https://docs.v${nextVersion}.archive.immich.app` }, - ...oldVersions, -]; +let versions = JSON.parse(readFileSync(filename)); +const newVersion = { + label: `v${nextVersion}`, + url: `https://docs.v${nextVersion}.archive.immich.app`, +}; -writeFileSync(filename, JSON.stringify(newVersions, null, 2) + '\n'); +let lastVersion = asVersion(newVersion); +for (const item of versions) { + const version = asVersion(item); + // only keep the latest patch version for each minor release + if ( + lastVersion.major === version.major && + lastVersion.minor === version.minor && + lastVersion.patch >= version.patch + ) { + versions = versions.filter((item) => item.label !== version.label); + console.log( + `Removed ${version.label} (replaced with ${lastVersion.label})` + ); + continue; + } + + lastVersion = version; +} + +writeFileSync( + filename, + JSON.stringify([newVersion, ...versions], null, 2) + '\n' +);