From 8565e2284e3cb5e3c473e789686013ce587c8ce4 Mon Sep 17 00:00:00 2001 From: hlorenzi Date: Wed, 3 Feb 2021 18:43:49 -0300 Subject: [PATCH] add version string --- .github/workflows/build_ghpages.yml | 3 +++ build-ghpages.bat | 1 + src/App.tsx | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/.github/workflows/build_ghpages.yml b/.github/workflows/build_ghpages.yml index 2b92294..38ae039 100644 --- a/.github/workflows/build_ghpages.yml +++ b/.github/workflows/build_ghpages.yml @@ -12,6 +12,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@master + with: + fetch-depth: 0 - name: Use Node.js 15.x uses: actions/setup-node@v1 @@ -28,6 +30,7 @@ jobs: - run: npm run build - run: git config user.name github-actions - run: git config user.email github-actions@github.com + - run: git describe --tags --match v* > build/build_version.txt - run: git add -A - run: git commit -m "build GitHub Pages" - run: git push -f origin ghpages \ No newline at end of file diff --git a/build-ghpages.bat b/build-ghpages.bat index 86a419f..411c58b 100644 --- a/build-ghpages.bat +++ b/build-ghpages.bat @@ -3,6 +3,7 @@ git checkout -b ghpages del .gitignore move .gitignore.ghpages .gitignore cmd /C npm run build +git describe --tags --match v* > build/build_version.txt git add -A git commit -m "build GitHub Pages" git push -f origin ghpages diff --git a/src/App.tsx b/src/App.tsx index 5de4b44..a420147 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -33,6 +33,20 @@ export default function App() const dockableCtx = Dockable.useDockableInit() const popupCtx = useRefState(() => Popup.getDefaultCtx()) + const [version, setVersion] = React.useState("") + + React.useEffect(() => + { + ;(async () => + { + const versionFile = await fetch("build/build_version.txt") + const versionTxt = await versionFile.text() + if (versionTxt.startsWith("v0-")) + setVersion("v0." + versionTxt.match(".*?\-(.*?)\-")![1]) + })() + + }, []) + React.useEffect(() => { @@ -91,6 +105,13 @@ export default function App() }}> How to use the app + + { version } + { !Playback.global.synthLoading ? null :