Fix version check partially (#2871)

ref #2748 

- fix link to releases
- fix jq syntax
- support rc versions (separate json field)

---------

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
qwerty287 2023-11-26 08:02:02 +01:00 committed by GitHub
parent 981384b79a
commit ffb3bd806c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 8 deletions

View file

@ -75,7 +75,8 @@ steps:
- git config --global user.name "woodpecker-bot" - git config --global user.name "woodpecker-bot"
- git clone --depth 1 --single-branch git@github.com:woodpecker-ci/woodpecker-ci.github.io.git /repo - git clone --depth 1 --single-branch git@github.com:woodpecker-ci/woodpecker-ci.github.io.git /repo
# update latest and next version # 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 - 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 # 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 - rsync -r --exclude .git --exclude CNAME --exclude index.yaml --exclude README.md --exclude version.json --delete docs/build/ /repo

2
web/components.d.ts vendored
View file

@ -67,10 +67,10 @@ declare module 'vue' {
IMdiGestureTap: typeof import('~icons/mdi/gesture-tap')['default'] IMdiGestureTap: typeof import('~icons/mdi/gesture-tap')['default']
IMdiGithub: typeof import('~icons/mdi/github')['default'] IMdiGithub: typeof import('~icons/mdi/github')['default']
IMdiLoading: typeof import('~icons/mdi/loading')['default'] IMdiLoading: typeof import('~icons/mdi/loading')['default']
IMdiSync: typeof import('~icons/mdi/sync')['default']
IMdiSourceBranch: typeof import('~icons/mdi/source-branch')['default'] IMdiSourceBranch: typeof import('~icons/mdi/source-branch')['default']
IMdisourceCommit: typeof import('~icons/mdi/source-commit')['default'] IMdisourceCommit: typeof import('~icons/mdi/source-commit')['default']
IMdiSourcePull: typeof import('~icons/mdi/source-pull')['default'] IMdiSourcePull: typeof import('~icons/mdi/source-pull')['default']
IMdiSync: typeof import('~icons/mdi/sync')['default']
IMdiTagOutline: typeof import('~icons/mdi/tag-outline')['default'] IMdiTagOutline: typeof import('~icons/mdi/tag-outline')['default']
InputField: typeof import('./src/components/form/InputField.vue')['default'] InputField: typeof import('./src/components/form/InputField.vue')['default']
IPhGitlabLogoSimpleFill: typeof import('~icons/ph/gitlab-logo-simple-fill')['default'] IPhGitlabLogoSimpleFill: typeof import('~icons/ph/gitlab-logo-simple-fill')['default']

View file

@ -10,12 +10,16 @@
<Error v-if="version?.needsUpdate"> <Error v-if="version?.needsUpdate">
<i18n-t keypath="update_woodpecker" tag="span"> <i18n-t keypath="update_woodpecker" tag="span">
<a <a
v-if="!version.usesNext"
:href="`https://github.com/woodpecker-ci/woodpecker/releases/tag/${version.latest}`" :href="`https://github.com/woodpecker-ci/woodpecker/releases/tag/${version.latest}`"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="underline" class="underline"
>{{ version.latest }}</a >{{ version.latest }}</a
> >
<span v-else>
{{ version.latest }}
</span>
</i18n-t> </i18n-t>
</Error> </Error>
</div> </div>

View file

@ -5,6 +5,7 @@ import useConfig from './useConfig';
type VersionInfo = { type VersionInfo = {
latest: string; latest: string;
rc: string;
next: string; next: string;
}; };
@ -13,6 +14,7 @@ const version = ref<{
current: string; current: string;
currentShort: string; currentShort: string;
needsUpdate: boolean; needsUpdate: boolean;
usesNext: boolean;
}>(); }>();
async function fetchVersion(): Promise<VersionInfo | undefined> { async function fetchVersion(): Promise<VersionInfo | undefined> {
@ -37,7 +39,7 @@ export function useVersion() {
const config = useConfig(); const config = useConfig();
const current = config.version as string; const current = config.version as string;
const usesNext = config.version?.startsWith('next'); const usesNext = current.startsWith('next');
const { user } = useAuthentication(); const { user } = useAuthentication();
if (!user?.admin) { if (!user?.admin) {
@ -46,6 +48,7 @@ export function useVersion() {
current, current,
currentShort: usesNext ? 'next' : current, currentShort: usesNext ? 'next' : current,
needsUpdate: false, needsUpdate: false,
usesNext,
}; };
return version; return version;
} }
@ -56,6 +59,7 @@ export function useVersion() {
current, current,
currentShort: current, currentShort: current,
needsUpdate: false, needsUpdate: false,
usesNext,
}; };
return version; return version;
} }
@ -63,20 +67,23 @@ export function useVersion() {
onMounted(async () => { onMounted(async () => {
const versionInfo = await fetchVersion(); const versionInfo = await fetchVersion();
let needsUpdate = false; let latest;
if (versionInfo) { if (versionInfo) {
if (usesNext) { if (usesNext) {
needsUpdate = versionInfo.next !== current; latest = versionInfo.next;
} else if (current.includes('rc')) {
latest = versionInfo.rc;
} else { } else {
needsUpdate = versionInfo.latest !== current; latest = versionInfo.latest;
} }
} }
version.value = { version.value = {
latest: usesNext ? versionInfo?.next : versionInfo?.latest, latest,
current, current,
currentShort: usesNext ? 'next' : current, currentShort: usesNext ? 'next' : current,
needsUpdate, needsUpdate: latest !== undefined && latest !== current,
usesNext,
}; };
}); });