diff --git a/.dockerignore b/.dockerignore index d0d9d082..e5a1d3f8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,5 +2,6 @@ .angular/ .idea/ .vscode/ +.nx/ dist/ node_modules/ diff --git a/.github/workflows/deploy.sh b/.github/workflows/deploy.sh new file mode 100644 index 00000000..38c9a63b --- /dev/null +++ b/.github/workflows/deploy.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +case "$GITHUB_REF" in + refs/tags/v*) TAG="${GITHUB_REF##*/}" ;; + *) TAG=latest ;; +esac +echo "Docker Tag: $TAG" +echo "tag=$TAG" >> $GITHUB_OUTPUT +V_VERSION="$(git describe --tags)" +echo "Git Describe Version: $V_VERSION" +echo "v_version=$V_VERSION" >> $GITHUB_OUTPUT +VERSION="${V_VERSION#v}" +echo "version=$VERSION" >> $GITHUB_OUTPUT diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 06b517d0..4feb9ec8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,6 +20,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set Deployment Options + id: deployment + run: .github/workflows/deploy.sh - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # https://docs.docker.com/build/ci/github-actions/push-multi-registries/ @@ -44,8 +47,10 @@ jobs: # ${{ github.repository_owner }} does not work. See https://github.com/orgs/community/discussions/27086 # If we ever move this to a different org, we need to update this line. tags: | - ${{ secrets.DOCKER_REGISTRY }}/apollusia/${{ matrix.app }} - ghcr.io/morphclue/apollusia-${{ matrix.app }} + ${{ secrets.DOCKER_REGISTRY }}/apollusia/${{ matrix.app }}:${{ steps.deployment.outputs.tag }} + ghcr.io/morphclue/apollusia-${{ matrix.app }}:${{ steps.deployment.outputs.tag }} + build-args: | + APP_VERSION=${{ steps.deployment.outputs.v_version }} cache-to: type=gha,mode=max cache-from: type=gha # https://github.com/sekassel-research/actions-rancher-update?tab=readme-ov-file#update-service @@ -58,4 +63,4 @@ jobs: project_id: ${{ secrets.RANCHER_PROJECT }} namespace: apollusia deployment: ${{ matrix.app }} - docker_image: ${{ secrets.DOCKER_REGISTRY }}/apollusia/${{ matrix.app }}:latest + docker_image: ${{ secrets.DOCKER_REGISTRY }}/apollusia/${{ matrix.app }}:${{ steps.deployment.outputs.tag }} diff --git a/apps/frontend/Dockerfile b/apps/frontend/Dockerfile index 9823302a..51092de4 100644 --- a/apps/frontend/Dockerfile +++ b/apps/frontend/Dockerfile @@ -3,7 +3,8 @@ WORKDIR /app COPY package.json pnpm-lock.yaml ./ RUN corepack pnpm install --frozen-lockfile COPY . . -RUN corepack pnpm run build:frontend +ARG APP_VERSION +RUN APP_VERSION=$APP_VERSION corepack pnpm run build:frontend FROM node:lts-slim WORKDIR /app diff --git a/apps/frontend/plugins/define-version.cjs b/apps/frontend/plugins/define-version.cjs new file mode 100644 index 00000000..3d8df196 --- /dev/null +++ b/apps/frontend/plugins/define-version.cjs @@ -0,0 +1,7 @@ +const plugin = { + name: 'define-version', + setup(build) { + build.initialOptions.define.APP_VERSION = JSON.stringify(process.env.APP_VERSION ?? 'v0.0.0'); + }, +}; +module.exports = plugin; diff --git a/apps/frontend/project.json b/apps/frontend/project.json index 57f59c64..dcfd70cc 100644 --- a/apps/frontend/project.json +++ b/apps/frontend/project.json @@ -29,6 +29,9 @@ "styles": ["apps/frontend/src/styles.scss"], "allowedCommonJsDependencies": ["validator"], "scripts": [], + "plugins": [ + "apps/frontend/plugins/define-version.cjs" + ], "serviceWorker": "apps/frontend/ngsw-config.json", "browser": "apps/frontend/src/main.ts", "server": "apps/frontend/src/main.server.ts", diff --git a/apps/frontend/src/app/core/navbar/navbar.component.html b/apps/frontend/src/app/core/navbar/navbar.component.html index e6aa13fa..b60a3a7a 100644 --- a/apps/frontend/src/app/core/navbar/navbar.component.html +++ b/apps/frontend/src/app/core/navbar/navbar.component.html @@ -90,6 +90,11 @@
Report a bug +
Copyright © Apollusia, {{ currentYear }}
diff --git a/apps/frontend/src/app/core/navbar/navbar.component.ts b/apps/frontend/src/app/core/navbar/navbar.component.ts index cc3269a2..f6ee1020 100644 --- a/apps/frontend/src/app/core/navbar/navbar.component.ts +++ b/apps/frontend/src/app/core/navbar/navbar.component.ts @@ -12,6 +12,17 @@ import {StorageService} from '../services/storage.service'; }) export class NavbarComponent { readonly currentYear = new Date().getFullYear(); + readonly version = APP_VERSION; + readonly changelogLink = (() => { + const [version, , commit] = APP_VERSION.split('-'); + if (commit) { + // e.g. v1.0.0-1-g1234567, git describe included the commit, so we show the diff + return `compare/${version}...${commit}`; + } else { + // for tagged versions, just link to the changelog + return `releases/tag/${version}`; + } + })(); themes = [ { diff --git a/apps/frontend/src/types.d.ts b/apps/frontend/src/types.d.ts new file mode 100644 index 00000000..bbe913ad --- /dev/null +++ b/apps/frontend/src/types.d.ts @@ -0,0 +1 @@ +declare const APP_VERSION: string;