From 3eb332c3a576526c075775bc4b5b119efd384a4a Mon Sep 17 00:00:00 2001 From: BrownKnight Date: Mon, 26 Aug 2024 17:40:08 +0100 Subject: [PATCH] Set version during github build --- .github/workflows/deploy.yml | 9 +++++++++ Dockerfile | 4 ++-- server/GridBattle.Data.Importer/Dockerfile | 3 ++- server/version.json => version.json | 0 4 files changed, 13 insertions(+), 3 deletions(-) rename server/version.json => version.json (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 11c54a4..80e754e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,6 +20,11 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dotnet/nbgv@master + id: nbgv - name: Log in to the Container registry uses: docker/login-action@v3 @@ -38,6 +43,8 @@ jobs: uses: docker/build-push-action@v6 with: context: . + build-args: + VERSION=${{ steps.nbgv.outputs.AssemblyInformationalVersion }} push: true tags: 'ghcr.io/brownknight/grid-battle:latest' cache-from: type=gha @@ -48,6 +55,8 @@ jobs: uses: docker/build-push-action@v6 with: context: . + build-args: + VERSION=${{ steps.nbgv.outputs.AssemblyInformationalVersion }} file: "./server/GridBattle.Data.Importer/Dockerfile" push: true tags: 'ghcr.io/brownknight/grid-battle-importer:latest' diff --git a/Dockerfile b/Dockerfile index 356fe39..3f89f2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,14 +3,14 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-server WORKDIR /source COPY ./server/Directory.* . -COPY ./server/version.json . COPY ./server/GridBattle.Data/GridBattle.Data.csproj GridBattle.Data/GridBattle.Data.csproj COPY ./server/GridBattle.Api/GridBattle.Api.csproj GridBattle.Api/GridBattle.Api.csproj RUN dotnet restore GridBattle.Api/GridBattle.Api.csproj COPY ./server/GridBattle.Data GridBattle.Data COPY ./server/GridBattle.Api GridBattle.Api -RUN dotnet publish GridBattle.Api/GridBattle.Api.csproj -c Release -o publish +ARG VERSION=0.0.1 +RUN dotnet publish GridBattle.Api/GridBattle.Api.csproj -c Release -o publish /p:Version=$VERSION FROM node:20 AS build-ui diff --git a/server/GridBattle.Data.Importer/Dockerfile b/server/GridBattle.Data.Importer/Dockerfile index 7e39ac4..a8629e0 100644 --- a/server/GridBattle.Data.Importer/Dockerfile +++ b/server/GridBattle.Data.Importer/Dockerfile @@ -9,7 +9,8 @@ RUN dotnet restore GridBattle.Data.Importer/GridBattle.Data.Importer.csproj COPY ./server/GridBattle.Data GridBattle.Data COPY ./server/GridBattle.Data.Importer GridBattle.Data.Importer -RUN dotnet publish GridBattle.Data.Importer/GridBattle.Data.Importer.csproj -c Release -o publish +ARG VERSION=0.0.1 +RUN dotnet publish GridBattle.Data.Importer/GridBattle.Data.Importer.csproj -c Release -o publish /p:Version=$VERSION FROM mcr.microsoft.com/dotnet/aspnet:8.0 diff --git a/server/version.json b/version.json similarity index 100% rename from server/version.json rename to version.json