From 95af82963f016a836b76ccdcffb4afb0ddcd7b06 Mon Sep 17 00:00:00 2001 From: Joel Biddle Date: Tue, 3 Oct 2023 05:55:36 +0000 Subject: [PATCH] Add version tags to Docker image & display on frontend --- .../workflows/build-docker-image-to-prod.yml | 26 ++++++++++++++++--- frontend/src/layouts/AppLayout/AppLayout.tsx | 6 +++++ frontend/src/version.ts | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 frontend/src/version.ts diff --git a/.github/workflows/build-docker-image-to-prod.yml b/.github/workflows/build-docker-image-to-prod.yml index 116ca0cf9..dddcf8159 100644 --- a/.github/workflows/build-docker-image-to-prod.yml +++ b/.github/workflows/build-docker-image-to-prod.yml @@ -39,7 +39,10 @@ jobs: token: ${{ secrets.DEPOT_PROJECT_TOKEN }} load: true context: backend - tags: infisical/backend:test + tags: | + infisical/backend:${{ steps.extract_version.outputs.version }} + labels: | + version=${{ steps.extract_version.outputs.version }} - name: ⏻ Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -58,9 +61,10 @@ jobs: context: backend tags: | infisical/backend:${{ steps.commit.outputs.short }} - infisical/backend:latest infisical/backend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64 + labels: | + version=${{ steps.extract_version.outputs.version }} frontend-image: name: Build frontend image @@ -90,9 +94,22 @@ jobs: token: ${{ secrets.DEPOT_PROJECT_TOKEN }} project: 64mmf0n610 context: frontend - tags: infisical/frontend:test + tags: | + infisical/frontend:${{ steps.extract_version.outputs.version }} build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + labels: | + version=${{ steps.extract_version.outputs.version }} + - name: 🛠️ Create or update Infisical version in version.ts file + run: | + version='${{ steps.extract_version.outputs.version }}' + file='frontend/src/version.ts' + touch "$file" + if grep -q "export const CURRENT_INFISICAL_VERSION = '.*';" "$file"; then + sed -i "s/export const CURRENT_INFISICAL_VERSION = '.*';/export const CURRENT_INFISICAL_VERSION = '$version';/" "$file" + else + echo "export const INFISICAL_VERSION = '$version';" >> "$file" + fi - name: ⏻ Spawn frontend container run: | docker run -d --rm --name infisical-frontend-test infisical/frontend:test @@ -111,8 +128,9 @@ jobs: context: frontend tags: | infisical/frontend:${{ steps.commit.outputs.short }} - infisical/frontend:latest infisical/frontend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + labels: | + version=${{ steps.extract_version.outputs.version }} \ No newline at end of file diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 8dd5f12ab..ed86b19b7 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -21,6 +21,7 @@ import { faCheck, faEnvelope, faInfinity, + faInfo, faMobile, faPlus, faQuestion @@ -68,6 +69,7 @@ import { useLogoutUser, useUploadWsKey } from "@app/hooks/api"; +import { CURRENT_INFISICAL_VERSION } from "@app/version" interface LayoutProps { children: React.ReactNode; @@ -696,6 +698,10 @@ export const AppLayout = ({ children }: LayoutProps) => { )} +
+ + Current version: {CURRENT_INFISICAL_VERSION} +
diff --git a/frontend/src/version.ts b/frontend/src/version.ts new file mode 100644 index 000000000..a170fa857 --- /dev/null +++ b/frontend/src/version.ts @@ -0,0 +1 @@ +export const CURRENT_INFISICAL_VERSION = "v1.1.1"; // placeholder - dynamically updated on prod build \ No newline at end of file