From 1725cc0b50d1dbb54b99a53fcf32ed04fda2f205 Mon Sep 17 00:00:00 2001 From: Lukas Gasselsberger Date: Wed, 11 Jan 2023 17:03:45 +0100 Subject: [PATCH] Retire `BuildNumber`, `BranchSpec` and `PullReuqestBase`, inject `GitHubActions` --- .github/workflows/build.yml | 3 --- .nuke/build.schema.json | 12 ------------ Build/Build.cs | 13 +++++++------ 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a05cc4a0c2..b7305a9b53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,9 +27,6 @@ jobs: - name: Run NUKE run: ./build.ps1 env: - BranchSpec: ${{ github.ref }} - BuildNumber: ${{ github.run_number }} - PullRequestBase: ${{ github.event.pull_request.base.ref }} ApiKey: ${{ secrets.NUGETAPIKEY }} - name: coveralls diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 37dcfce118..a25782bb66 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -10,14 +10,6 @@ "type": "string", "description": "The key to push to Nuget" }, - "BranchSpec": { - "type": "string", - "description": "A branch specification such as develop or refs/pull/1775/merge" - }, - "BuildNumber": { - "type": "string", - "description": "An incrementing build number as provided by the build engine" - }, "Continue": { "type": "boolean", "description": "Indicates to continue a previously failed build attempt" @@ -66,10 +58,6 @@ "type": "string" } }, - "PullRequestBase": { - "type": "string", - "description": "The target branch for the pull request" - }, "Root": { "type": "string", "description": "Root directory during build execution" diff --git a/Build/Build.cs b/Build/Build.cs index b28a375a7d..c1ba36faa3 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -3,6 +3,7 @@ using System.Linq; using LibGit2Sharp; using Nuke.Common; +using Nuke.Common.CI.GitHubActions; using Nuke.Common.Execution; using Nuke.Common.Git; using Nuke.Common.IO; @@ -32,14 +33,14 @@ class Build : NukeBuild public static int Main() => Execute(x => x.SpellCheck, x => x.Push); - [Parameter("A branch specification such as develop or refs/pull/1775/merge")] - readonly string BranchSpec; + GitHubActions GitHubActions => GitHubActions.Instance; - [Parameter("An incrementing build number as provided by the build engine")] - readonly string BuildNumber; + string BranchSpec => GitHubActions?.Ref; + string BuildNumber => GitHubActions?.RunNumber.ToString(); + string PullRequestBase => GitHubActions?.BaseRef; - [Parameter("The target branch for the pull request")] - readonly string PullRequestBase; + [Parameter] + readonly string GithubToken; [Parameter("The key to push to Nuget")] readonly string ApiKey;