diff --git a/.github/workflows/deploy-images.yml b/.github/workflows/deploy-images.yml index d3d70b90b..ccc2104bc 100644 --- a/.github/workflows/deploy-images.yml +++ b/.github/workflows/deploy-images.yml @@ -18,12 +18,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get version + id: vars + run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - name: Build Client Docker image run: | docker build \ -t ghcr.io/bluewave-labs/checkmate-client:latest \ -f ./docker/dist/client.Dockerfile \ --label org.opencontainers.image.source=https://github.com/bluewave-labs/checkmate \ + --build-arg VITE_APP_VERSION=${{ env.VERSION }} \ . - name: Push Client Docker image @@ -96,6 +100,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get version + id: vars + run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + - name: Build and push multi-arch Docker image uses: docker/build-push-action@v5 with: @@ -107,6 +115,8 @@ jobs: platforms: linux/amd64,linux/arm64 labels: | org.opencontainers.image.source=https://github.com/bluewave-labs/checkmate + build-args: | + VITE_APP_VERSION=${{ env.VERSION }} docker-build-and-push-server-mono: runs-on: ubuntu-latest diff --git a/.github/workflows/production-deploy.yml b/.github/workflows/production-deploy.yml index 6956f5caa..4275b4a00 100644 --- a/.github/workflows/production-deploy.yml +++ b/.github/workflows/production-deploy.yml @@ -18,12 +18,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get version + id: vars + run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - name: Build Client Docker image run: | docker build \ -t ghcr.io/bluewave-labs/checkmate:frontend-demo \ -f ./docker/prod/client.Dockerfile \ --label org.opencontainers.image.source=https://github.com/bluewave-labs/checkmate \ + --build-arg VITE_APP_VERSION=${{ env.VERSION }} \ . - name: Push Client Docker image diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 34fa243c6..de0dbfed4 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -18,12 +18,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get version + id: vars + run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - name: Build Client Docker image run: | docker build \ -t ghcr.io/bluewave-labs/checkmate:frontend-staging \ -f ./docker/staging/client.Dockerfile \ --label org.opencontainers.image.source=https://github.com/bluewave-labs/checkmate \ + --build-arg VITE_APP_VERSION=${{ env.VERSION }} \ . - name: Push Client Docker image diff --git a/client/vite.config.js b/client/vite.config.js index 96151c0b3..e930a20e9 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -5,13 +5,14 @@ import { execSync } from "child_process"; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ""); - let version; - try { - version = - env.VITE_APP_VERSION || - execSync("git describe --tags --abbrev=0").toString().trim(); - } catch (error) { - version = "unknown"; + let version = env.VITE_APP_VERSION; + + if (!version) { + try { + version = execSync("git describe --tags --abbrev=0").toString().trim(); + } catch { + version = "unknown"; + } } return {