Skip to content

Commit

Permalink
docs: version Go SDK installs
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Aug 29, 2024
1 parent fe26019 commit 9b4a388
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
6 changes: 4 additions & 2 deletions docs/getting-started/integrate-auth/01_go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ sidebar_label: Go
import Teaser from '../_common/teaser.mdx'
import mp4 from '../_static/go/screencast.mp4'
import webm from '../_static/go/screencast.webm'
import CodeBlock from "@theme/CodeBlock"
import { useLatestTag } from '@site/src/hooks'
<Teaser
framework={<a href="https://go.dev/">Go</a>}
Expand All @@ -32,8 +34,8 @@ go mod init github.com/<your-name>/your-project

Run this command to install the Ory SDK which allows you to interact with Ory APIs:

```shell-session
go get -u github.com/ory/client-go
```mdx-code-block
<CodeBlock className="language-shell">{`go get github.com/ory/client-go@${useLatestTag('client-go', 'master')}`}</CodeBlock>
```

## Install Ory CLI
Expand Down
7 changes: 5 additions & 2 deletions docs/hydra/sdk/05_go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ Don't consume the `/oauth2/auth` and `/oauth2/token` endpoints using this SDK. U

To install the Go SDK, run:

```go
go get github.com/ory/client-go
```mdx-code-block
import CodeBlock from "@theme/CodeBlock"
import { useLatestTag } from '@site/src/hooks'
<CodeBlock className="language-shell">{`go get github.com/ory/client-go@${useLatestTag('client-go', 'master')}`}</CodeBlock>
```

## Making requests
Expand Down
7 changes: 5 additions & 2 deletions docs/keto/sdk/05_go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ Ory Permissions exposes two APIs for integration

### Installation REST API

```go
go get github.com/ory/client-go
```mdx-code-block
import CodeBlock from "@theme/CodeBlock"
import { useLatestTag } from '@site/src/hooks'
<CodeBlock className="language-shell">{`go get github.com/ory/client-go@${useLatestTag('client-go', 'master')}`}</CodeBlock>
```

### Installation gRPC API
Expand Down
5 changes: 3 additions & 2 deletions docs/kratos/sdk/05_go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: Go
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
import CodeBlock from "@theme/CodeBlock"
import { useLatestTag } from '@site/src/hooks'
```

In this document you can find code examples for the Ory Identities Go SDK.
Expand Down Expand Up @@ -34,8 +35,8 @@ go mod init myproject

Install the Ory Go SDK

```go
go get github.com/ory/client-go
```mdx-code-block
<CodeBlock className="language-shell">{`go get github.com/ory/client-go@${useLatestTag('client-go', 'master')}`}</CodeBlock>
```

## Frontend API
Expand Down
28 changes: 28 additions & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function useLatestRelease(
per_page: 100,
})
.then(({ data }) => {
console.log(data)
const published = data.filter(
({ draft, tag_name }) => !draft && !tag_name.match(/pre.[0-9]+$/),
)
Expand All @@ -85,6 +86,33 @@ export function useLatestRelease(

return release
}
/**
* Returns the latest tag for a repo.
*
* @param repo
* @param fallback
*/
export function useLatestTag(repo: string, fallback = "<version-you-want>") {
const [release, setRelease] = useState<string>(fallback)

useEffect(() => {
octokit.repos
.listTags({
owner: "ory",
repo,
per_page: 100,
})
.then(({ data }) => {
console.log(data)
const published = data.filter((a) => !a.name.match(/pre.[0-9]+$/))
if (published.length > 0) {
setRelease(published[0].name)
}
})
}, [repo])

return release
}

/**
* Returns the latest release filename tag
Expand Down

0 comments on commit 9b4a388

Please sign in to comment.