Skip to content

Commit 3286198

Browse files
also provide a function that can return the version, so we can use it
outside of code blocks
1 parent 1013d30 commit 3286198

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

docs/admin/deploy/docker-compose/upgrade.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ git merge {CURRENT_VERSION}
2424

2525
For each conflict, you need to reconcile any customizations you made with the updates from the new version. Use the information you gathered earlier from the change log and changes list to interpret the merge conflict and to ensure that it doesn't over-write your customizations. You may need to update your customizations to accommodate the new version.
2626

27-
> NOTE: If you have made no changes or only very minimal changes to your configuration, you can also ask git to always select incoming changes in the event of merge conflicts. In the following example merges will be accepted from the upstream version {CURREN_VERSION_STRING}:
27+
> NOTE: If you have made no changes or only very minimal changes to your configuration, you can also ask git to always select incoming changes in the event of merge conflicts. In the following example merges will be accepted from the upstream version {CURREN_VERSION_STRING()}:
2828
>
2929
> `git merge -X theirs {CURRENT_VERSION_STRING}`
3030
>

docs/admin/deploy/repositories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ You can now deploy using your private copy of the repository you've just created
6464

6565
Before you can upgrade Sourcegraph, you will first update your private copy with the upstream branch, and then merge the upstream release tag for the next minor version into your release branch.
6666

67-
In the following example, the release branch is being upgraded to {CURRENT_VERSION_STRING}.
67+
In the following example, the release branch is being upgraded to {CURRENT_VERSION_STRING()}.
6868

6969
```bash
7070
export YOUR_RELEASE_BRANCH=release-$SG_DEPLOY_VERSION

src/components/PreCodeBlock.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import { CopyButton } from '@/components/CopyButton'
2-
import React, { DetailedHTMLProps, HTMLAttributes, Children, useEffect, useState } from 'react'
2+
import React, { DetailedHTMLProps, HTMLAttributes, Children } from 'react'
33

44
interface PreProps extends DetailedHTMLProps<HTMLAttributes<HTMLPreElement>, HTMLPreElement> {
55
raw?: string
66
}
77

8+
interface ReleaseInfo {
9+
id: number;
10+
name: string;
11+
public: boolean;
12+
created_at: string;
13+
promoted_at: string;
14+
version: string;
15+
git_sha: string;
16+
is_development: boolean;
17+
tags: string[] | null;
18+
canonical_name: string;
19+
}
20+
821
async function getLatestVersion() {
922
const url = new URL('https://releaseregistry.sourcegraph.com/v1/releases/sourcegraph/latest');
1023

@@ -19,11 +32,14 @@ async function getLatestVersion() {
1932
throw new Error(`HTTP error! status: ${response.status}`);
2033
}
2134

22-
return await response.json();
35+
const releaseInfo: ReleaseInfo = await response.json();
36+
return releaseInfo.version
2337
}
2438

25-
const CURRENT_VERSION_S = getLatestVersion()
26-
export const CURRENT_VERSION_STRING = CURRENT_VERSION_S.version
39+
export async function CURRENT_VERSION_STRING() {
40+
const v = await getLatestVersion()
41+
return v
42+
}
2743

2844
export async function PreCodeBlock({ children, ...props }: PreProps) {
2945
const propsObj = { ...props }
@@ -43,8 +59,7 @@ export async function PreCodeBlock({ children, ...props }: PreProps) {
4359
}
4460

4561
const version = await getLatestVersion()
46-
const latestVersion = version.version
47-
codeContent = codeContent.replace(/{CURRENT_VERSION}/g, latestVersion)
62+
codeContent = codeContent.replace(/{CURRENT_VERSION}/g, version)
4863

4964
return (
5065
<div className="relative">

0 commit comments

Comments
 (0)