From 8c272ab6ffe219a8c48fdba53725dac2eb710e11 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 9 Nov 2024 02:32:42 +0100 Subject: [PATCH] CI: add app version --- .forgejo/workflows/build.yaml | 10 ++++++++-- build.yaml | 5 +++++ package.json | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 75fffe2..c02c209 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -4,7 +4,7 @@ on: inputs: build: description: "Build container" - required: false + required: true default: false type: boolean @@ -50,6 +50,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: Update version.json from git describe + run: pnpm run version + - name: Build package (transpile ts => js) run: ng build @@ -63,6 +66,8 @@ jobs: tags: ${{ steps.version.outputs.version }} containerfiles: | ./Containerfile + build-args: | + APP_VERSION=${{ steps.version.outputs.version }} - name: Workaround for bug of podman-login if: fromJSON(steps.builder.outputs.run) @@ -79,8 +84,9 @@ jobs: password: ${{ secrets.REGISTRY_PASSWORD }} auth_file_path: /tmp/auth.json - - uses: actions/push-to-registry@v2 + - name: Push the image to the registry if: fromJSON(steps.builder.outputs.run) + uses: actions/push-to-registry@v2 with: registry: "docker://${{ vars.REGISTRY }}" image: treetrail-frontend diff --git a/build.yaml b/build.yaml index 8b195eb..0bd92e0 100644 --- a/build.yaml +++ b/build.yaml @@ -23,6 +23,11 @@ args: chdir: "{{ playbook_dir }}" + - name: Update version.json + command: pnpm run version + args: + chdir: "{{ playbook_dir }}" + - name: Build frontend container containers.podman.podman_image: name: "treetrail-frontend:{{ version.stdout }}" diff --git a/package.json b/package.json index 6cac1dd..43ef986 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", - "openapi-ts": "openapi-ts" + "openapi-ts": "openapi-ts", + "version": "echo \"{\\\"version\\\":\\\"$(git describe --tags --dirty --always)\\\"}\" > src/version.json" }, "private": true, "dependencies": {