-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch latest tag from github api
- Loading branch information
Showing
4 changed files
with
66 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
project(your_awesome_app LANGUAGES CXX VERSION 1.0) | ||
|
||
# -------------------------------------------------------------------------------------------------------- | ||
# Create executable | ||
# -------------------------------------------------------------------------------------------------------- | ||
|
||
add_executable(${PROJECT_NAME} "main.cpp") | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON) | ||
|
||
# -------------------------------------------------------------------------------------------------------- | ||
# Link libraries | ||
# -------------------------------------------------------------------------------------------------------- | ||
|
||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
saucer | ||
GIT_REPOSITORY "https://github.com/saucer/saucer" | ||
GIT_TAG v$VERSION$ | ||
) | ||
|
||
FetchContent_MakeAvailable(saucer) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE saucer::saucer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import CodeBlock, { Props } from "@theme/CodeBlock"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
export function VersionedCode({ children, ...props }: Props) | ||
{ | ||
const [version, setVersion] = useState("v2.0.1"); | ||
|
||
useEffect(() => | ||
{ | ||
fetch("https://api.github.com/repos/saucer/saucer/releases/latest", { headers: [ | ||
["Accept", "application/vnd.github+json"], | ||
["X-GitHub-Api-Version", "2022-11-28"] | ||
] }).then(data => | ||
{ | ||
data.json().then(json => | ||
{ | ||
setVersion(json["tag_name"] ?? version); | ||
}); | ||
}); | ||
|
||
|
||
}, []); | ||
|
||
return <CodeBlock {...props}> | ||
{children.toString().replace("$VERSION$", version.replace(/[^0-9.]/, ""))} | ||
</CodeBlock>; | ||
} |