From 8e28ff6eb09a53b5f174d064b34982c44f6fbf3a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 5 Apr 2024 10:51:12 +0200 Subject: [PATCH] build ci on tag creation --- .github/workflows/main.yml | 6 +++--- Docs/overrides/conceptual.extension.js | 3 --- build.cake | 17 ++++++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f3ecaa..3bc9321 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: - name: Run cake uses: coactions/setup-xvfb@v1 with: - run: dotnet cake --target Publish --branch ${{ github.ref_name }} + run: dotnet cake --target Publish --ref ${{ github.ref }} --run ${{ github.run_number }} env: NUGET_KEY: ${{ secrets.NUGET_KEY }} BAGET_KEY: ${{ secrets.BAGET_KEY }} @@ -41,9 +41,9 @@ jobs: - name: Restore tools run: dotnet tool restore - name: Run cake - run: dotnet cake --target Document --branch $GITHUB_REF_NAME + run: dotnet cake --target Document --ref ${{ github.ref }} --run ${{ github.run_number }} - name: Deploy - if: github.event_name == 'push' && github.ref_name == 'release' + if: startsWith(github.ref, 'refs/tags/') # this is a beautiful way to deploy a website and i will not take any criticism run: | curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && sudo dpkg -i cloudflared.deb diff --git a/Docs/overrides/conceptual.extension.js b/Docs/overrides/conceptual.extension.js index 62e881d..8a30c9e 100644 --- a/Docs/overrides/conceptual.extension.js +++ b/Docs/overrides/conceptual.extension.js @@ -1,8 +1,5 @@ exports.preTransform = function (model) { if (model._path.includes("index")) { - // point to the release branch in the readme - model.conceptual = model.conceptual.replaceAll(/\/MLEM(\/[^/]+)?\/main\//g, "/MLEM$1/release/"); - // reduce header levels by 1 to allow for TOC navigation for (let i = 5; i >= 1; i--) model.conceptual = model.conceptual.replaceAll(` { DotNetWorkloadInstall("android"); + DotNetRestore("MLEM.sln"); DotNetRestore("MLEM.FNA.sln"); - if (branch != "release") { - var buildNum = EnvironmentVariable("GITHUB_RUN_NUMBER"); - if (!string.IsNullOrEmpty(buildNum)) - version += "-ci." + buildNum; + if (!gitRef.StartsWith("refs/tags/") && !string.IsNullOrEmpty(buildNum)) { + Information($"Appending {buildNum} to version"); + version += $"-ci.{buildNum}"; } DeleteFiles("**/MLEM*.nupkg"); @@ -52,14 +53,16 @@ Task("Pack").IsDependentOn("Test").Does(() => { DotNetPack("MLEM.FNA.sln", settings); }); -Task("Push").WithCriteria(branch == "main" || branch == "release", "Not on main or release branch").IsDependentOn("Pack").Does(() => { +Task("Push").WithCriteria(gitRef == "refs/heads/main" || gitRef.StartsWith("refs/tags/"), "Not on main branch or tag").IsDependentOn("Pack").Does(() => { DotNetNuGetPushSettings settings; - if (branch == "release") { + if (gitRef.StartsWith("refs/tags/")) { + Information("Pushing to public feed"); settings = new DotNetNuGetPushSettings { Source = "https://api.nuget.org/v3/index.json", ApiKey = EnvironmentVariable("NUGET_KEY") }; } else { + Information("Pushing to private feed"); settings = new DotNetNuGetPushSettings { Source = "https://nuget.ellpeck.de/v3/index.json", ApiKey = EnvironmentVariable("BAGET_KEY")