From fa3207927b6017fb7879942e356a4afc44033b21 Mon Sep 17 00:00:00 2001 From: Robert Bill Date: Mon, 4 May 2026 11:30:12 +0200 Subject: [PATCH 1/6] Replace nbgv with gitversion --- Directory.Build.props | 11 +++++------ GitVersion.yaml | 5 +++++ Server/Api/SiteApi.cs | 2 +- Server/Program.cs | 2 +- version.json | 17 ----------------- 5 files changed, 12 insertions(+), 25 deletions(-) create mode 100644 GitVersion.yaml delete mode 100644 version.json diff --git a/Directory.Build.props b/Directory.Build.props index b07434c..391973c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,11 +1,5 @@  - - - all - 3.9.50 - - closure.ch © 2024-2026 Closure OSS Contributors @@ -18,4 +12,9 @@ true + + + All + + \ No newline at end of file diff --git a/GitVersion.yaml b/GitVersion.yaml new file mode 100644 index 0000000..e611680 --- /dev/null +++ b/GitVersion.yaml @@ -0,0 +1,5 @@ +workflow: GitHubFlow/v1 +mode: ContinuousDelivery +branches: + feature: + mode: ContinuousDelivery diff --git a/Server/Api/SiteApi.cs b/Server/Api/SiteApi.cs index 06ef4e7..ce498c3 100644 --- a/Server/Api/SiteApi.cs +++ b/Server/Api/SiteApi.cs @@ -24,7 +24,7 @@ public static RouteGroupBuilder MapSiteApi(this RouteGroupBuilder api) { var response = new FeatureResponse { - Version = ThisAssembly.AssemblyInformationalVersion, + Version = GitVersionInformation.SemVer, PathBase = env.PathBase, }; foreach (var feature in Enum.GetValues()) diff --git a/Server/Program.cs b/Server/Program.cs index b1a705f..30db3a4 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -98,7 +98,7 @@ c.SwaggerDoc("v1", new OpenApiInfo { Title = "Calendare Server", - Version = ThisAssembly.AssemblyFileVersion, + Version = GitVersionInformation.SemVer, Description = "Administration API for the Calendare Server", Contact = new OpenApiContact { diff --git a/version.json b/version.json deleted file mode 100644 index 54ec3b9..0000000 --- a/version.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.7-alpha.{height}", - "publicReleaseRefSpec": [ - "^refs/heads/main$", - "^refs/heads/release/v\\d+(?:\\.\\d+)?$" - ], - "cloudBuild": { - "setAllVariables": true, - "buildNumber": { - "enabled": true - } - }, - "release": { - "branchName": "release/v{version}" - } -} \ No newline at end of file From 359f0ce1a7699a56bac2bd5312b2b1486844a8e3 Mon Sep 17 00:00:00 2001 From: Robert Bill Date: Mon, 4 May 2026 11:36:02 +0200 Subject: [PATCH 2/6] Update workflow --- .github/workflows/dotnet.yml | 53 +++++++++++++++++++ .../{build.yml => release-container.yml} | 0 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/dotnet.yml rename .github/workflows/{build.yml => release-container.yml} (100%) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..877733d --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,53 @@ +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net +name: 🏭 Build executables + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + branches: + - main + +env: + DOTNET_VERSION: "10.x" + +permissions: + contents: write + pull-requests: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + cache: true + cache-dependency-path: "**/packages.lock.json" + + - name: Restore dependencies + run: dotnet restore --locked-mode + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v4.5.0 + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v4.5.0 + with: + updateProjectFiles: true + + - name: Build + run: dotnet build --no-restore -c Release + + - name: Test + run: dotnet test --no-build -c Release --verbosity normal + diff --git a/.github/workflows/build.yml b/.github/workflows/release-container.yml similarity index 100% rename from .github/workflows/build.yml rename to .github/workflows/release-container.yml From 4b47c610aa69d22f0e2c95bb0677f1c1ade66609 Mon Sep 17 00:00:00 2001 From: Robert Bill <147130488+RobSlgm@users.noreply.github.com> Date: Mon, 4 May 2026 12:45:42 +0200 Subject: [PATCH 3/6] Build action --- .github/workflows/dotnet.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 877733d..766a8d3 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -30,11 +30,11 @@ jobs: uses: actions/setup-dotnet@v5 with: dotnet-version: ${{ env.DOTNET_VERSION }} - cache: true - cache-dependency-path: "**/packages.lock.json" + # cache: true + # cache-dependency-path: "**/packages.lock.json" - name: Restore dependencies - run: dotnet restore --locked-mode + run: dotnet restore - name: Install GitVersion uses: gittools/actions/gitversion/setup@v4.5.0 @@ -45,9 +45,14 @@ jobs: with: updateProjectFiles: true - - name: Build + - name: Build server run: dotnet build --no-restore -c Release - name: Test run: dotnet test --no-build -c Release --verbosity normal + - name: Build database migration + working-directory: Data + run: | + dotnet tool install dotnet-ef + dotnet ef migrations bundle --self-contained -r linux-x64 --force -o ../artifacts/efbundle \ No newline at end of file From 02d2be4040e5448b53f7ec144fefd333f561c291 Mon Sep 17 00:00:00 2001 From: Robert Bill <147130488+RobSlgm@users.noreply.github.com> Date: Mon, 4 May 2026 14:40:59 +0200 Subject: [PATCH 4/6] Update workflow --- .github/workflows/release-container.yml | 105 ++++++++++++++++-------- GitVersion.yaml | 5 ++ 2 files changed, 78 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release-container.yml b/.github/workflows/release-container.yml index 29cf1c8..e5ae1a2 100644 --- a/.github/workflows/release-container.yml +++ b/.github/workflows/release-container.yml @@ -1,18 +1,16 @@ name: 🏭 Build Calendare Server on: - workflow_dispatch: - # push: - # branches: - # - release/** - # - main - # pull_request: - # branches: - # - main + push: + tags: + - "v[0-9]*.[0-9]*.[0-9]*" # Pattern for standard: v1.2.3 + - "v[0-9]*.[0-9]*.[0-9]*-*" # Pattern for pre-release: v1.2.3-alpha.1 env: REGISTRY: ghcr.io + # PROJECT_PATH: "HcloudMetallbController/HcloudMetallbController.csproj" CHART_REPO: charts + DOTNET_VERSION: "10.x" jobs: build: @@ -22,28 +20,32 @@ jobs: packages: write steps: - - uses: actions/checkout@v6 + - name: Checkout code + uses: actions/checkout@v6 with: fetch-depth: 0 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: 10.x - - - uses: dotnet/nbgv@v0.4.2 - id: meta - with: - setAllVars: true - - - name: Prepare lower case names - id: migr + - name: Extract repo names + id: repoinfo + shell: bash run: | REPOSITORY_LC=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') echo "repository_lc=$REPOSITORY_LC" >> $GITHUB_OUTPUT REPOSITORY_OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') echo "repository_owner_lc=$REPOSITORY_OWNER_LC" >> $GITHUB_OUTPUT + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v4.5.0 + + - name: Determine Version + id: meta + uses: gittools/actions/gitversion/execute@v4.5.0 + - name: Log in to registry uses: docker/login-action@v4 with: @@ -53,9 +55,13 @@ jobs: - name: Publish server container to registry env: - REPOSITORY_LC: ${{ steps.migr.outputs.repository_lc }} + REPOSITORY_LC: ${{ steps.repoinfo.outputs.repository_lc }} IMAGE_NAME: "calendare-server" - ContainerImageTags: "${{ steps.meta.outputs.SemVer2 }};${{ steps.meta.outputs.MajorMinorVersion }};${{ steps.meta.outputs.Version }};latest" + ContainerImageTags: >- + ${{ steps.meta.outputs.PreReleaseLabel != '' + && format('{0};{1};{2}', steps.meta.outputs.SemVer, steps.meta.outputs.MajorMinorPath, steps.meta.outputs.InformationalVersion) + || format('{0};{1}.{2};{3};latest', steps.meta.outputs.SemVer, steps.meta.outputs.Major, steps.meta.outputs.Minor, steps.meta.outputs.InformationalVersion) + }} run: | dotnet publish --os linux --arch x64 /t:PublishContainer \ -p ContainerRegistry=${{ env.REGISTRY }} \ @@ -71,6 +77,7 @@ jobs: uses: docker/setup-buildx-action@v4 - name: Build and push database migration container image + if: steps.meta.outputs.PreReleaseLabel == '' uses: docker/build-push-action@v7 with: context: . @@ -78,18 +85,52 @@ jobs: push: true # sbom: true build-args: | - BUILD_DATE=${{ steps.meta.outputs.GitCommitDate }} - SEMVER2=${{ steps.meta.outputs.SemVer2 }} + BUILD_DATE=${{ steps.meta.outputs.CommitDate }} + SEMVER2=${{ steps.meta.outputs.SemVer }} tags: | - ${{ env.REGISTRY }}/${{ steps.migr.outputs.repository_lc }}/calendare-migration:latest - ${{ env.REGISTRY }}/${{ steps.migr.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.SemVer2 }} - ${{ env.REGISTRY }}/${{ steps.migr.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.MajorMinorVersion }} - ${{ env.REGISTRY }}/${{ steps.migr.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.Version }} + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:latest + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.SemVer }} + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.MajorMinorPatch }} + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.Major }}.${{ steps.meta.outputs.Minor }} + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.InformationalVersion }} + + - name: Build and push database migration container image (pre-release) + if: steps.meta.outputs.PreReleaseLabel != '' + uses: docker/build-push-action@v7 + with: + context: . + file: ./Containerfile.migration + push: true + # sbom: true + build-args: | + BUILD_DATE=${{ steps.meta.outputs.CommitDate }} + SEMVER2=${{ steps.meta.outputs.SemVer }} + tags: | + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.SemVer }} + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.MajorMinorPatch }} + ${{ env.REGISTRY }}/${{ steps.repoinfo.outputs.repository_lc }}/calendare-migration:${{ steps.meta.outputs.InformationalVersion }} + + - name: Get chart name + id: chartname + uses: mikefarah/yq@master + with: + cmd: yq -r .name deploy/Chart.yaml - name: Push Helm chart env: - VERSION: ${{ steps.meta.outputs.SemVer2 }} - REPOSITORY_OWNER_LC: ${{ steps.migr.outputs.repository_owner_lc }} + VERSION: ${{ steps.meta.outputs.SemVer }} + REPOSITORY_OWNER_LC: ${{ steps.repoinfo.outputs.repository_owner_lc }} + CHART_NAME: ${{ steps.chartname.outputs.result }} run: | helm package ./deploy --version "$VERSION" --app-version "$VERSION" - helm push calendare-${VERSION}.tgz oci://${{ env.REGISTRY }}/${REPOSITORY_OWNER_LC}/${{ env.CHART_REPO }} + helm push ${CHART_NAME}-${VERSION}.tgz oci://${{ env.REGISTRY }}/${REPOSITORY_OWNER_LC}/${{ env.CHART_REPO }} + + - name: Create Release + uses: softprops/action-gh-release@v3 + if: github.ref_type == 'tag' + with: + tag_name: ${{ github.ref_name }} + name: "${{ github.ref_name }}" + generate_release_notes: true + draft: false + prerelease: ${{ steps.gitversion.outputs.PreReleaseTag != '' }} diff --git a/GitVersion.yaml b/GitVersion.yaml index e611680..bf21a15 100644 --- a/GitVersion.yaml +++ b/GitVersion.yaml @@ -1,5 +1,10 @@ workflow: GitHubFlow/v1 mode: ContinuousDelivery branches: + main: + label: "beta" feature: mode: ContinuousDelivery +assembly-versioning-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}' +assembly-file-versioning-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}' +assembly-informational-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}' \ No newline at end of file From 5973576c39e79ec0bfd76ee93ad4a8bbcc741ac2 Mon Sep 17 00:00:00 2001 From: Robert Bill <147130488+RobSlgm@users.noreply.github.com> Date: Mon, 4 May 2026 14:45:58 +0200 Subject: [PATCH 5/6] Fix permission --- .github/workflows/release-container.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-container.yml b/.github/workflows/release-container.yml index e5ae1a2..889b72f 100644 --- a/.github/workflows/release-container.yml +++ b/.github/workflows/release-container.yml @@ -16,8 +16,9 @@ jobs: build: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write + pull-requests: read steps: - name: Checkout code From 55b72a888d8643b0c02ac9fa5f275badcb2f0fb6 Mon Sep 17 00:00:00 2001 From: Robert Bill <147130488+RobSlgm@users.noreply.github.com> Date: Mon, 4 May 2026 14:48:08 +0200 Subject: [PATCH 6/6] Fix permission --- .github/workflows/release-container.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-container.yml b/.github/workflows/release-container.yml index 889b72f..3d6627d 100644 --- a/.github/workflows/release-container.yml +++ b/.github/workflows/release-container.yml @@ -8,7 +8,6 @@ on: env: REGISTRY: ghcr.io - # PROJECT_PATH: "HcloudMetallbController/HcloudMetallbController.csproj" CHART_REPO: charts DOTNET_VERSION: "10.x"