From 8935627f18d49034121991dae9e56e0b80e47b6c Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 3 Nov 2023 16:14:35 +0100 Subject: [PATCH 1/7] add version and update notes --- .woodpecker/docs.yml | 13 ++-- web/components.d.ts | 2 + .../admin/settings/AdminInfoTab.vue | 21 ++++++ web/src/components/layout/header/Navbar.vue | 7 +- web/src/compositions/useVersion.ts | 64 +++++++++++++++++++ web/src/views/admin/AdminSettings.vue | 4 ++ 6 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 web/src/components/admin/settings/AdminInfoTab.vue create mode 100644 web/src/compositions/useVersion.ts diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml index 2a03519ab9..c5ada30e7a 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/docs.yml @@ -1,4 +1,5 @@ when: + - event: tag - event: pull_request - event: push path: &when_path @@ -59,7 +60,7 @@ steps: secrets: - BOT_PRIVATE_KEY commands: - - apk add openssh-client git rsync + - apk add openssh-client git rsync jq - mkdir -p $HOME/.ssh - ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts - echo "$BOT_PRIVATE_KEY" > $HOME/.ssh/id_rsa @@ -67,8 +68,11 @@ steps: - git config --global user.email "woodpecker-bot@obermui.de" - 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 + - $${CI_PIPELINE_EVENT} == "tag" && jq --arg version "${CI_COMMIT_TAG}" '.latest = $version' repo/version.json > repo/version.json + - $${CI_PIPELINE_EVENT} == "push" && jq --arg version "next-${CI_COMMIT_SHA:0:10}" '.next = $version' repo/version.json > repo/version.json # 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 --delete docs/build/ /repo + - rsync -r --exclude .git --exclude CNAME --exclude index.yaml --exclude README.md --exclude version.json --delete docs/build/ /repo - cd /repo - git add . # exit successfully if nothing changed @@ -76,5 +80,6 @@ steps: - git commit -m "Deploy website - based on ${CI_COMMIT_SHA}" - git push when: - event: [push, cron] - path: *when_path + - event: [push, cron] + path: *when_path + - event: tag diff --git a/web/components.d.ts b/web/components.d.ts index fe8f5baecb..d2cdd02957 100644 --- a/web/components.d.ts +++ b/web/components.d.ts @@ -10,6 +10,7 @@ declare module 'vue' { ActionsTab: typeof import('./src/components/repo/settings/ActionsTab.vue')['default'] ActivePipelines: typeof import('./src/components/layout/header/ActivePipelines.vue')['default'] AdminAgentsTab: typeof import('./src/components/admin/settings/AdminAgentsTab.vue')['default'] + AdminInfoTab: typeof import('./src/components/admin/settings/AdminInfoTab.vue')['default'] AdminOrgsTab: typeof import('./src/components/admin/settings/AdminOrgsTab.vue')['default'] AdminQueueStats: typeof import('./src/components/admin/settings/queue/AdminQueueStats.vue')['default'] AdminQueueTab: typeof import('./src/components/admin/settings/AdminQueueTab.vue')['default'] @@ -22,6 +23,7 @@ declare module 'vue' { Checkbox: typeof import('./src/components/form/Checkbox.vue')['default'] CheckboxesField: typeof import('./src/components/form/CheckboxesField.vue')['default'] Container: typeof import('./src/components/layout/Container.vue')['default'] + copy: typeof import('./src/components/admin/settings/AdminAgentsTab copy.vue')['default'] CronTab: typeof import('./src/components/repo/settings/CronTab.vue')['default'] DeployPipelinePopup: typeof import('./src/components/layout/popups/DeployPipelinePopup.vue')['default'] DocsLink: typeof import('./src/components/atomic/DocsLink.vue')['default'] diff --git a/web/src/components/admin/settings/AdminInfoTab.vue b/web/src/components/admin/settings/AdminInfoTab.vue new file mode 100644 index 0000000000..a61bbe170b --- /dev/null +++ b/web/src/components/admin/settings/AdminInfoTab.vue @@ -0,0 +1,21 @@ + + + diff --git a/web/src/components/layout/header/Navbar.vue b/web/src/components/layout/header/Navbar.vue index f664571845..d197a428e2 100644 --- a/web/src/components/layout/header/Navbar.vue +++ b/web/src/components/layout/header/Navbar.vue @@ -8,7 +8,9 @@ - {{ version }} + {{ + version?.currentShort + }} @@ -55,9 +57,11 @@ import Button from '~/components/atomic/Button.vue'; import IconButton from '~/components/atomic/IconButton.vue'; import useAuthentication from '~/compositions/useAuthentication'; import useConfig from '~/compositions/useConfig'; +import { useVersion } from '~/compositions/useVersion'; import ActivePipelines from './ActivePipelines.vue'; +const version = useVersion(); const config = useConfig(); const route = useRoute(); const authentication = useAuthentication(); @@ -68,7 +72,6 @@ function doLogin() { authentication.authenticate(route.fullPath); } -const version = config.version?.startsWith('next') ? 'next' : config.version; const { enableSwagger } = config; diff --git a/web/src/compositions/useVersion.ts b/web/src/compositions/useVersion.ts new file mode 100644 index 0000000000..c6a1349af8 --- /dev/null +++ b/web/src/compositions/useVersion.ts @@ -0,0 +1,64 @@ +import { onMounted, ref } from 'vue'; + +import useConfig from './useConfig'; + +type VersionInfo = { + latest: string; + next: string; +}; + +const version = ref<{ + latest: string | undefined; + current: string; + currentShort: string; + needsUpdate: boolean; +}>(); + +async function fetchVersion(): Promise { + try { + const resp = await fetch('https://woodpecker-ci.org/version.json'); + const json = await resp.json(); + return json; + } catch (error) { + // eslint-disable-next-line no-console + console.error('Failed to fetch version info', error); + return undefined; + } +} + +const isInitialised = ref(false); + +export function useVersion() { + if (isInitialised.value) { + return version; + } + isInitialised.value = true; + + const config = useConfig(); + + onMounted(async () => { + const versionInfo = await fetchVersion(); + + console.log(versionInfo); + + const current = config.version as string; + const usesNext = config.version?.startsWith('next'); + let needsUpdate = false; + if (versionInfo) { + if (usesNext) { + needsUpdate = versionInfo.next !== current; + } else { + needsUpdate = versionInfo.latest !== current; + } + } + + version.value = { + latest: usesNext ? versionInfo?.next : versionInfo?.latest, + current, + currentShort: usesNext ? 'next' : current, + needsUpdate, + }; + }); + + return version; +} diff --git a/web/src/views/admin/AdminSettings.vue b/web/src/views/admin/AdminSettings.vue index fc15dd377d..4abc0a1b76 100644 --- a/web/src/views/admin/AdminSettings.vue +++ b/web/src/views/admin/AdminSettings.vue @@ -3,6 +3,9 @@ + + + @@ -30,6 +33,7 @@ import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; import AdminAgentsTab from '~/components/admin/settings/AdminAgentsTab.vue'; +import AdminInfoTab from '~/components/admin/settings/AdminInfoTab.vue'; import AdminOrgsTab from '~/components/admin/settings/AdminOrgsTab.vue'; import AdminQueueTab from '~/components/admin/settings/AdminQueueTab.vue'; import AdminReposTab from '~/components/admin/settings/AdminReposTab.vue'; From 7f594e1c5c229d6ed12662924107e08356eb4817 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 3 Nov 2023 21:26:09 +0100 Subject: [PATCH 2/7] improve info --- web/src/assets/locales/en.json | 5 ++- .../admin/settings/AdminInfoTab.vue | 17 +++++--- web/src/components/layout/header/Navbar.vue | 39 +++++++++---------- web/src/compositions/useVersion.ts | 21 +++++++--- web/src/views/admin/AdminSettings.vue | 2 +- 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/web/src/assets/locales/en.json b/web/src/assets/locales/en.json index 3ca1936a3f..c08c0c98f6 100644 --- a/web/src/assets/locales/en.json +++ b/web/src/assets/locales/en.json @@ -501,5 +501,8 @@ "internal_error": "Some internal error occurred", "access_denied": "You are not allowed to login" }, - "default": "default" + "default": "default", + "info": "Systeminfo", + "running_version": "You are running woodpecker", + "update_woodpecker": "Please update your Woodpecker instance to" } diff --git a/web/src/components/admin/settings/AdminInfoTab.vue b/web/src/components/admin/settings/AdminInfoTab.vue index a61bbe170b..fe56e32e05 100644 --- a/web/src/components/admin/settings/AdminInfoTab.vue +++ b/web/src/components/admin/settings/AdminInfoTab.vue @@ -1,13 +1,20 @@ diff --git a/web/src/components/layout/header/Navbar.vue b/web/src/components/layout/header/Navbar.vue index d197a428e2..cb8e9ec38d 100644 --- a/web/src/components/layout/header/Navbar.vue +++ b/web/src/components/layout/header/Navbar.vue @@ -1,49 +1,46 @@ From 3b6544423fb8c25c679a17ab62f7d26103409e3f Mon Sep 17 00:00:00 2001 From: Anbraten Date: Sat, 4 Nov 2023 10:59:26 +0100 Subject: [PATCH 5/7] improve version update --- .woodpecker/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml index c5ada30e7a..0498765b02 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/docs.yml @@ -69,8 +69,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 - - $${CI_PIPELINE_EVENT} == "tag" && jq --arg version "${CI_COMMIT_TAG}" '.latest = $version' repo/version.json > repo/version.json - - $${CI_PIPELINE_EVENT} == "push" && jq --arg version "next-${CI_COMMIT_SHA:0:10}" '.next = $version' repo/version.json > repo/version.json + - 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" == "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 - cd /repo From f8e527a5ab80dc2666de0e5b3d2f51ff18d4c6f4 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Sat, 4 Nov 2023 11:26:51 +0100 Subject: [PATCH 6/7] skip fetch on dev --- web/src/compositions/useVersion.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/web/src/compositions/useVersion.ts b/web/src/compositions/useVersion.ts index b30a982b28..6243966359 100644 --- a/web/src/compositions/useVersion.ts +++ b/web/src/compositions/useVersion.ts @@ -47,6 +47,17 @@ export function useVersion() { currentShort: usesNext ? 'next' : current, needsUpdate: false, }; + return version; + } + + if (current === 'dev') { + version.value = { + latest: undefined, + current, + currentShort: current, + needsUpdate: false, + }; + return version; } onMounted(async () => { @@ -54,9 +65,7 @@ export function useVersion() { let needsUpdate = false; if (versionInfo) { - if (current === 'dev') { - needsUpdate = false; - } else if (usesNext) { + if (usesNext) { needsUpdate = versionInfo.next !== current; } else { needsUpdate = versionInfo.latest !== current; From 3b53b7075b26002cd741ee6ef8a176394bf73322 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Sat, 4 Nov 2023 12:16:54 +0100 Subject: [PATCH 7/7] removed version color --- web/src/components/layout/header/Navbar.vue | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/web/src/components/layout/header/Navbar.vue b/web/src/components/layout/header/Navbar.vue index cb8e9ec38d..322a90f77a 100644 --- a/web/src/components/layout/header/Navbar.vue +++ b/web/src/components/layout/header/Navbar.vue @@ -5,12 +5,7 @@
- {{ version?.currentShort }} + {{ version?.currentShort }} {{ $t('repos') }}