Skip to content

Commit

Permalink
Merge branch 'h17-rework-version-information' into development
Browse files Browse the repository at this point in the history
# Conflicts:
#	client/package-lock.json
#	client/package.json
  • Loading branch information
Timtam committed Dec 3, 2024
2 parents 326104c + 4ea5030 commit c270627
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 55 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/push_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: "get hitster version"
run: |
cd client
npm i @corteks/gitversion
export HITSTER_VERSION=$(npm run version --silent)
-
name: Build and push Docker dev image
if: startsWith(github.ref, 'refs/heads/development')
Expand All @@ -43,6 +49,7 @@ jobs:
tags: tonironaldbarth/hitster:dev
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: HITSTER_VERSION=${{ HITSTER_VERSION }}
-
name: Build and push Docker stable image
if: startsWith(github.ref, 'refs/tags') && !github.event_type != 'pull_request'
Expand All @@ -54,3 +61,4 @@ jobs:
tags: tonironaldbarth/hitster:latest , tonironaldbarth/hitster:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: HITSTER_VERSION=${{ HITSTER_VERSION }}
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:20 AS client_build_image

ARG HITSTER_VERSION

WORKDIR /app

# build cache first
Expand All @@ -10,7 +12,7 @@ RUN npm install && rm /app/*.json

# build everything else

COPY ./client/ ./server/Cargo.toml /app/
COPY ./client/ /app/

RUN npm run build

Expand Down
16 changes: 8 additions & 8 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "hitster-client",
"private": true,
"version": "0.2.0",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build-dev": "tsc && vite build --sourcemap true --minify false",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"version": "node -e \"import('@corteks/gitversion').then(({getFormattedVersion: _}) => _().then((v) => console.log(v)))\""
},
"dependencies": {
"@lomray/event-manager": "^2.0.2",
Expand Down Expand Up @@ -40,6 +41,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@corteks/gitversion": "^0.3.4",
"@types/boolify-string": "^0.0.32",
"@types/howler": "^2.2.11",
"@types/react": "^18.2.56",
Expand All @@ -54,7 +56,6 @@
"eslint-plugin-react-refresh": "^0.4.5",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^4.1.0",
"toml": "^3.0.0",
"typescript": "^5.2.2",
"vite": "^5.1.4",
"vite-plugin-checker": "^0.8.0",
Expand Down
2 changes: 1 addition & 1 deletion client/src/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"howToPlay": "Wie wird gespielt?",
"allRightsReserved": "Alle Rechte vorbehalten",
"sourceCodeAvailableAt": "Quellcode verfügbar auf <0>GitHub</0>",
"version": "Client-Version: {{clientVersion}} | Server-Version: {{serverVersion}}",
"version": "Version: {{version}}",
"ownedBy": "Diese inoffizielle Version basiert auf dem originalen Hitster-Kartenspiel, welches <0>Koninklijke Jumbo B.V.</0> gehört.",
"issue": "Für Lob, Kritik oder Fehlermeldungen, eröffnen Sie bitte ein <0>Issue auf GitHub</0>.",
"mainMenu": "Hauptmenü",
Expand Down
2 changes: 1 addition & 1 deletion client/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"howToPlay": "How to play the game",
"allRightsReserved": "All rights reserved",
"sourceCodeAvailableAt": "Source Code available at <0>GitHub</0>",
"version": "Client Version: {{clientVersion}} | Server Version: {{serverVersion}}",
"version": "Version: {{version}}",
"ownedBy": "This unofficial version is based on the original Hitster card game which is owned by <0>Koninklijke Jumbo B.V.</0>.",
"issue": "For bug reports and general feedback please open a <0>GitHub issue</0>.",
"mainMenu": "Main menu",
Expand Down
3 changes: 1 addition & 2 deletions client/src/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export default function Navigation({ user }: { user: User | null }) {
</p>
<p className="mb-6 px-2 fs-6 text-nowrap">
{t("version", {
clientVersion: "__CLIENT_VERSION__",
serverVersion: "__SERVER_VERSION__",
version: "__VERSION__",
})}
</p>
<p className="mb-3 px-2 fs-6 text-nowrap">
Expand Down
67 changes: 29 additions & 38 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
import { getFormattedVersion } from "@corteks/gitversion"
import react from "@vitejs/plugin-react-swc"
import fs from "fs"
import toml from "toml"
import { defineConfig, splitVendorChunkPlugin } from "vite"
import checker from "vite-plugin-checker"
import replace from "vite-plugin-filter-replace"
import viteTsconfigPaths from "vite-tsconfig-paths"
import pkg from "./package.json"

let server_version: string = "UNKNOWN"
// https://vitejs.dev/config/
export default defineConfig(async () => {
let version: string = process.env.HITSTER_VERSION ?? await getFormattedVersion()

try {
server_version = toml.parse(
fs.readFileSync("../server/Cargo.toml", { encoding: "utf-8" }),
).package.version
} catch (e) {
server_version = toml.parse(
fs.readFileSync("./Cargo.toml", { encoding: "utf-8" }),
).package.version
}
if(version === "0.0.0-null") {
// fallback
version = "unknown"
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
viteTsconfigPaths(),
checker({
typescript: true,
}),
splitVendorChunkPlugin(),
replace([
{
filter: "src/navigation.tsx",
replace: [
{
from: /__CLIENT_VERSION__/g,
to: pkg.version,
},
{
from: /__SERVER_VERSION__/g,
to: server_version,
},
],
},
]),
],
return {
plugins: [
react(),
viteTsconfigPaths(),
checker({
typescript: true,
}),
splitVendorChunkPlugin(),
replace([
{
filter: "src/navigation.tsx",
replace: [
{
from: /__VERSION__/g,
to: version,
},
],
},
]),
],
}
})
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hitster-server"
version = "0.2.1"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down

0 comments on commit c270627

Please sign in to comment.