diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 6280867aa..1505e8d68 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -3,6 +3,8 @@ on: push: branches: - main + # Publish semver tags as releases + tags: [ '*.*.*' ] pull_request: jobs: test: diff --git a/.github/workflows/saas.yml b/.github/workflows/saas.yml index f91254686..0b7a45ef7 100644 --- a/.github/workflows/saas.yml +++ b/.github/workflows/saas.yml @@ -67,6 +67,16 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # Extract version from tag if this is a tag push + - name: Extract version from tag + id: get_version + if: startsWith(github.ref, 'refs/tags/') + run: | + VERSION=${GITHUB_REF#refs/tags/} + VERSION=${VERSION#v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Release version: $VERSION" + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image @@ -74,7 +84,9 @@ jobs: uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 with: context: . - build-args: SAAS=1 + build-args: | + SAAS=1 + ${{ startsWith(github.ref, 'refs/tags/') && format('VERSION={0}', steps.get_version.outputs.version) || '' }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 184ec9e44..a47b19b90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM node:22-slim AS front_builder +ARG VERSION +ARG SAAS SHELL ["/bin/bash", "-c"] WORKDIR /app/frontend COPY frontend/package.json frontend/yarn.lock frontend/angular.json frontend/tsconfig.app.json frontend/tsconfig.json /app/frontend/ @@ -7,8 +9,17 @@ RUN apt-get update && apt-get install -y \ git \ && rm -rf /var/lib/apt/lists/* RUN yarn install --immutable --network-timeout 1000000 --silent +COPY frontend/scripts /app/frontend/scripts COPY frontend/src /app/frontend/src -ARG SAAS + +# Update version if VERSION build arg is provided +RUN if [[ -n $VERSION ]]; then \ + cd frontend; \ + echo "Updating package.json version to $VERSION" && \ + npm version $VERSION --no-git-tag-version && \ + yarn update-version; \ + fi + RUN if [[ -n $SAAS ]]; then API_ROOT=/api yarn build --configuration=saas-production; \ else API_ROOT=/api yarn build --configuration=production; fi RUN ls /app/frontend/dist/dissendium-v0 @@ -21,7 +32,7 @@ RUN apt-get update && apt-get install -y \ tini nginx \ make gcc g++ python3 \ libxml2 \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY package.json .yarnrc.yml yarn.lock /app/