From da217c1627be8bf074040320c8d308e2008638c7 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 9 Oct 2022 21:54:21 +0200 Subject: [PATCH] Update CI --- .config/dotnet-tools.json | 2 +- .github/workflows/main.yml | 7 ++++++- build.cake | 20 +++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 6cf141e..7bd5f9f 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "1.1.0", + "version": "2.2.0", "commands": [ "dotnet-cake" ] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f5ecfe..e2f13de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,12 @@ jobs: path: Reactor.Debugger/bin/Release/net6.0/Reactor.Debugger.dll - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') + if: github.ref_type == 'tag' with: draft: true files: Reactor/bin/Release/net6.0/Reactor.dll + + - name: Push nightly NuGet package + if: github.repository == 'NuclearPowered/Reactor' && github.ref == 'refs/heads/master' + run: | + dotnet nuget push Reactor/bin/Release/Reactor.*.nupkg --source https://nuget.reactor.gg/v3/index.json --api-key ${{ secrets.REACTOR_NUGET_KEY }} diff --git a/build.cake b/build.cake index 3bbd153..68a5ca1 100644 --- a/build.cake +++ b/build.cake @@ -1,33 +1,31 @@ var target = Argument("target", "Build"); -var buildId = EnvironmentVariable("GITHUB_RUN_NUMBER"); - -var @ref = EnvironmentVariable("GITHUB_REF"); -const string prefix = "refs/tags/"; -var tag = !string.IsNullOrEmpty(@ref) && @ref.StartsWith(prefix) ? @ref.Substring(prefix.Length) : null; +var workflow = BuildSystem.GitHubActions.Environment.Workflow; +var buildId = workflow.RunNumber; +var tag = workflow.RefType == GitHubActionsRefType.Tag ? workflow.RefName : null; Task("Build") .Does(() => { - var settings = new DotNetCoreBuildSettings + var settings = new DotNetBuildSettings { Configuration = "Release", - MSBuildSettings = new DotNetCoreMSBuildSettings() + MSBuildSettings = new DotNetMSBuildSettings() }; if (tag != null) { - settings.MSBuildSettings.Properties["Version"] = new[] { tag }; + settings.MSBuildSettings.Version = tag; } - else if (buildId != null) + else if (buildId != 0) { - settings.VersionSuffix = "ci." + buildId; + settings.MSBuildSettings.VersionSuffix = "ci." + buildId; } foreach (var gamePlatform in new[] { "Steam", "Itch" }) { settings.MSBuildSettings.Properties["GamePlatform"] = new[] { gamePlatform }; - DotNetCoreBuild(".", settings); + DotNetBuild(".", settings); } });