mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
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:
parent
981384b79a
commit
ffb3bd806c
4 changed files with 20 additions and 8 deletions
|
@ -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
|
||||
|
|
2
web/components.d.ts
vendored
2
web/components.d.ts
vendored
|
@ -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']
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
<Error v-if="version?.needsUpdate">
|
||||
<i18n-t keypath="update_woodpecker" tag="span">
|
||||
<a
|
||||
v-if="!version.usesNext"
|
||||
:href="`https://github.com/woodpecker-ci/woodpecker/releases/tag/${version.latest}`"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="underline"
|
||||
>{{ version.latest }}</a
|
||||
>
|
||||
<span v-else>
|
||||
{{ version.latest }}
|
||||
</span>
|
||||
</i18n-t>
|
||||
</Error>
|
||||
</div>
|
||||
|
|
|
@ -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<VersionInfo | undefined> {
|
||||
|
@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue