From ffb3bd806c8bfb4d063ad97244abc43b0b4c4ec7 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Sun, 26 Nov 2023 08:02:02 +0100 Subject: [PATCH] Fix version check partially (#2871) ref #2748 - fix link to releases - fix jq syntax - support rc versions (separate json field) --------- Co-authored-by: Anbraten --- .woodpecker/docs.yml | 3 ++- web/components.d.ts | 2 +- .../admin/settings/AdminInfoTab.vue | 4 ++++ web/src/compositions/useVersion.ts | 19 +++++++++++++------ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml index dc8e438b8..2df2241fb 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/docs.yml @@ -75,7 +75,8 @@ steps: - git config --global user.name "woodpecker-bot" - git clone --depth 1 --single-branch git@github.com:woodpecker-ci/woodpecker-ci.github.io.git /repo # update latest and next version - - if [ "$CI_PIPELINE_EVENT" == "tag" ] ; then jq '.latest = ${CI_COMMIT_TAG}' /repo/version.json > /repo/version.json.tmp && mv /repo/version.json.tmp /repo/version.json ; fi + - if [[ "$CI_PIPELINE_EVENT" == "tag" && "${CI_COMMIT_TAG}" != *"rc"* ]] ; then jq '.latest = "${CI_COMMIT_TAG}"' /repo/version.json > /repo/version.json.tmp && mv /repo/version.json.tmp /repo/version.json ; fi + - if [[ "$CI_PIPELINE_EVENT" == "tag" ]] ; then jq '.rc = "${CI_COMMIT_TAG}"' /repo/version.json > /repo/version.json.tmp && mv /repo/version.json.tmp /repo/version.json ; fi - if [ "$CI_PIPELINE_EVENT" == "push" ] ; then jq '.next = "next-${CI_COMMIT_SHA:0:10}"' /repo/version.json > /repo/version.json.tmp && mv /repo/version.json.tmp /repo/version.json ; fi # copy all docs files and delete all old ones, but leave CNAME and index.yaml untouched - rsync -r --exclude .git --exclude CNAME --exclude index.yaml --exclude README.md --exclude version.json --delete docs/build/ /repo diff --git a/web/components.d.ts b/web/components.d.ts index 778ecc8cf..94980ba6a 100644 --- a/web/components.d.ts +++ b/web/components.d.ts @@ -67,10 +67,10 @@ declare module 'vue' { IMdiGestureTap: typeof import('~icons/mdi/gesture-tap')['default'] IMdiGithub: typeof import('~icons/mdi/github')['default'] IMdiLoading: typeof import('~icons/mdi/loading')['default'] - IMdiSync: typeof import('~icons/mdi/sync')['default'] IMdiSourceBranch: typeof import('~icons/mdi/source-branch')['default'] IMdisourceCommit: typeof import('~icons/mdi/source-commit')['default'] IMdiSourcePull: typeof import('~icons/mdi/source-pull')['default'] + IMdiSync: typeof import('~icons/mdi/sync')['default'] IMdiTagOutline: typeof import('~icons/mdi/tag-outline')['default'] InputField: typeof import('./src/components/form/InputField.vue')['default'] IPhGitlabLogoSimpleFill: typeof import('~icons/ph/gitlab-logo-simple-fill')['default'] diff --git a/web/src/components/admin/settings/AdminInfoTab.vue b/web/src/components/admin/settings/AdminInfoTab.vue index 22dd6b48b..aaba1ef45 100644 --- a/web/src/components/admin/settings/AdminInfoTab.vue +++ b/web/src/components/admin/settings/AdminInfoTab.vue @@ -10,12 +10,16 @@ {{ version.latest }} + + {{ version.latest }} + diff --git a/web/src/compositions/useVersion.ts b/web/src/compositions/useVersion.ts index 624396635..a7f3eb2ec 100644 --- a/web/src/compositions/useVersion.ts +++ b/web/src/compositions/useVersion.ts @@ -5,6 +5,7 @@ import useConfig from './useConfig'; type VersionInfo = { latest: string; + rc: string; next: string; }; @@ -13,6 +14,7 @@ const version = ref<{ current: string; currentShort: string; needsUpdate: boolean; + usesNext: boolean; }>(); async function fetchVersion(): Promise { @@ -37,7 +39,7 @@ export function useVersion() { const config = useConfig(); const current = config.version as string; - const usesNext = config.version?.startsWith('next'); + const usesNext = current.startsWith('next'); const { user } = useAuthentication(); if (!user?.admin) { @@ -46,6 +48,7 @@ export function useVersion() { current, currentShort: usesNext ? 'next' : current, needsUpdate: false, + usesNext, }; return version; } @@ -56,6 +59,7 @@ export function useVersion() { current, currentShort: current, needsUpdate: false, + usesNext, }; return version; } @@ -63,20 +67,23 @@ export function useVersion() { onMounted(async () => { const versionInfo = await fetchVersion(); - let needsUpdate = false; + let latest; if (versionInfo) { if (usesNext) { - needsUpdate = versionInfo.next !== current; + latest = versionInfo.next; + } else if (current.includes('rc')) { + latest = versionInfo.rc; } else { - needsUpdate = versionInfo.latest !== current; + latest = versionInfo.latest; } } version.value = { - latest: usesNext ? versionInfo?.next : versionInfo?.latest, + latest, current, currentShort: usesNext ? 'next' : current, - needsUpdate, + needsUpdate: latest !== undefined && latest !== current, + usesNext, }; });