Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version check partially #2871

Merged
merged 6 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .woodpecker/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
anbraten marked this conversation as resolved.
Show resolved Hide resolved
- 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
Expand Down
2 changes: 1 addition & 1 deletion web/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/admin/settings/AdminInfoTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
19 changes: 13 additions & 6 deletions web/src/compositions/useVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useConfig from './useConfig';

type VersionInfo = {
latest: string;
rc: string;
next: string;
};

Expand All @@ -13,6 +14,7 @@ const version = ref<{
current: string;
currentShort: string;
needsUpdate: boolean;
usesNext: boolean;
}>();

async function fetchVersion(): Promise<VersionInfo | undefined> {
Expand All @@ -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) {
Expand All @@ -46,6 +48,7 @@ export function useVersion() {
current,
currentShort: usesNext ? 'next' : current,
needsUpdate: false,
usesNext,
};
return version;
}
Expand All @@ -56,27 +59,31 @@ export function useVersion() {
current,
currentShort: current,
needsUpdate: false,
usesNext,
};
return version;
}

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')) {
anbraten marked this conversation as resolved.
Show resolved Hide resolved
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,
};
});

Expand Down