Skip to content

Commit

Permalink
Try PR number again (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Apr 8, 2024
1 parent c3d8a70 commit 27e743a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variables:
CONFIGURATION: 'Release'
BUILD_PRERELEASE: true
DOTNET_CORE_VERSION: 8.x
PR_NUMBER: $[coalesce(variables['System.PullRequest.PullRequestNumber'], '0')]

jobs:
- job: pack
Expand All @@ -26,7 +27,7 @@ jobs:
dotnet tool restore
displayName: Restore .NET tools
- pwsh: |
dotnet cake --target=Pack --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
dotnet cake --target=Pack --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$(PR_NUMBER)"
displayName: Pack
- task: PublishBuildArtifacts@1
displayName: Publish NuGet packages
Expand All @@ -50,7 +51,7 @@ jobs:
dotnet tool restore
displayName: Restore .NET tools
- pwsh: |
dotnet cake --target=Build --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
dotnet cake --target=Build --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$(PR_NUMBER)"
displayName: Build
- job: test
Expand All @@ -69,7 +70,7 @@ jobs:
dotnet tool restore
displayName: Restore .NET tools
- pwsh: |
dotnet cake --target=Test --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
dotnet cake --target=Test --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$(PR_NUMBER)"
displayName: Run tests
- task: PublishBuildArtifacts@1
displayName: Publish artifacts
Expand Down
6 changes: 3 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var pullrequest = Argument("pullrequest", "");
var prerelease = Argument("prerelease", true) || !string.IsNullOrEmpty(pullrequest);
var pullrequest = Argument("pullrequest", 0);
var prerelease = Argument("prerelease", true) || pullrequest > 0;

// a bit of logic to create the version number:
// - input = 1.2.3.4
Expand All @@ -13,7 +13,7 @@ var assemblyVersion = $"{version.Major}.0.0.0";
var fileVersion = $"{version.Major}.{version.Minor}.{version.Build}.0";
var infoVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
var packageVersion = $"{version.Major}.{version.Minor}.{version.Build}";
var previewlabel = string.IsNullOrEmpty(pullrequest) ? "preview" : $"pr.{pullrequest}";
var previewlabel = pullrequest > 0 ? $"pr.{pullrequest}" : "preview";
var previewVersion = $"{packageVersion}-{previewlabel}.{previewNumber}";
var finalBuildNumber = prerelease ? previewVersion : packageVersion;

Expand Down

0 comments on commit 27e743a

Please sign in to comment.