-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from Oxalate-Portal/add_buildinfo_functionality
Add version awareness as well as package building in GHA
- Loading branch information
Showing
13 changed files
with
166 additions
and
16 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
VITE_APP_API_URL=http://localhost:8080/api | ||
VITE_APP_RECAPTCHA_SITE_KEY = "You need to generate this key from Google Recaptcha" | ||
VITE_APP_OXALATE_PAGE_TITLE = "Oxalate Portal" | ||
VITE_APP_OXALATE_COPYRIGHT_FOOTER = "© 2024 - Oxalate Portal project" | ||
VITE_APP_OXALATE_COPYRIGHT_FOOTER = "Oxalate Portal project © 2024" | ||
VITE_APP_POWERED_BY_OXALATE = "Powered by <a href="https://oxalate.io/">Oxalate Portal</a>" |
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,5 @@ | ||
VITE_APP_API_URL=http://localhost:8080/api | ||
VITE_APP_RECAPTCHA_SITE_KEY = "6LfGtFImAAAAAG9fADR3SUfA2sb0zXSYvZrFtPhT" | ||
VITE_APP_OXALATE_PAGE_TITLE = "Oxalate Portal" | ||
VITE_APP_OXALATE_COPYRIGHT_FOOTER = "Oxalate Portal project © 2024" | ||
VITE_APP_POWERED_BY_OXALATE = "Powered by <a href="https://oxalate.io/">Oxalate Portal</a>" |
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 @@ | ||
0.9 |
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,55 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
const dayjs = require("dayjs"); | ||
|
||
function gitFetch() { | ||
try { | ||
execSync('git fetch', { stdio: 'inherit' }); | ||
} catch (error) { | ||
console.error('Error fetching the latest changes from the repository:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
function getLatestTag() { | ||
try { | ||
return execSync('git describe --tags --abbrev=0').toString().trim(); | ||
} catch (error) { | ||
return null; | ||
} | ||
} | ||
|
||
function getNextVersion(currentVersion, latestTag) { | ||
const [currentMajor, currentMinor] = currentVersion.split('.').map(Number); | ||
|
||
if (latestTag) { | ||
const [latestMajor, latestMinor, latestPatch] = latestTag.split('.').map(Number); | ||
|
||
if (currentMajor === latestMajor && currentMinor === latestMinor) { | ||
return `${currentMajor}.${currentMinor}.${latestPatch + 1}`; | ||
} | ||
} | ||
|
||
return `${currentMajor}.${currentMinor}.0`; | ||
} | ||
|
||
const versionFilePath = path.resolve(__dirname, 'VERSION'); | ||
const currentVersion = fs.readFileSync(versionFilePath, 'utf8').trim(); | ||
|
||
gitFetch(); | ||
|
||
const latestTag = getLatestTag(); | ||
const nextVersion = getNextVersion(currentVersion, latestTag); | ||
|
||
const buildTime = new Date().toISOString(); | ||
const buildTimeFormatted = dayjs(buildTime).format("YYYY.MM.DD HH:mm") | ||
const outputFilePath = path.resolve(__dirname, 'src/buildInfo.json'); | ||
|
||
fs.writeFileSync(outputFilePath, JSON.stringify({ buildTime: buildTimeFormatted, version: nextVersion }), 'utf8'); | ||
|
||
console.log("=================================================================================="); | ||
console.log("Generating build time and version..."); | ||
console.log(`Build time: ${buildTimeFormatted}`); | ||
console.log(`Next version: ${nextVersion}`); | ||
console.log("=================================================================================="); |
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
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,18 @@ | ||
import BuildInfoData from "../../buildInfo.json"; | ||
import {Footer} from "antd/es/layout/layout"; | ||
import {BuildInfo} from "../../models"; | ||
|
||
function OxalateFooter() { | ||
const buildInfo: BuildInfo = BuildInfoData; | ||
|
||
return ( | ||
<Footer style={{textAlign: "center"}} | ||
dangerouslySetInnerHTML={{ | ||
__html: import.meta.env.VITE_APP_OXALATE_COPYRIGHT_FOOTER + "<br/>" | ||
+ "v" + buildInfo.version + " " + " built: " + buildInfo.buildTime + "<br/>" | ||
+ import.meta.env.VITE_APP_POWERED_BY_OXALATE | ||
}}/> | ||
); | ||
} | ||
|
||
export {OxalateFooter}; |
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,4 @@ | ||
export interface BuildInfo { | ||
buildTime: string; | ||
version: string; | ||
} |
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