From 38a10565da44620373e4ddeff614905b800f6154 Mon Sep 17 00:00:00 2001 From: "REDMOND\\acoates" Date: Wed, 19 Jun 2019 15:55:28 -0700 Subject: [PATCH 1/5] Add commit Id to nuget pacakges --- .ado/bumpFileVersions.js | 8 ------ .ado/publish.yml | 35 ++++++++++++-------------- .ado/templates/prep-and-pack-nuget.yml | 22 ++++++---------- .ado/updateVersion.js | 5 ++++ vnext/ReactUwp.nuspec | 4 +++ vnext/ReactWin32.nuspec | 4 +++ vnext/package.json | 2 +- 7 files changed, 37 insertions(+), 43 deletions(-) delete mode 100644 .ado/bumpFileVersions.js diff --git a/.ado/bumpFileVersions.js b/.ado/bumpFileVersions.js deleted file mode 100644 index 717d48eecf6..00000000000 --- a/.ado/bumpFileVersions.js +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-check -// Just bump the local version numbers in the files... - -const { - updateVersionsInFiles, -} = require("./versionUtils"); - -updateVersionsInFiles(); diff --git a/.ado/publish.yml b/.ado/publish.yml index 5e891d30f42..7d8b20ea182 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -37,17 +37,11 @@ jobs: - task: CmdLine@2 displayName: Update package version + name: updateVersionTask inputs: script: node ../.ado/updateVersion.js workingDirectory: vnext - # since the above task will update the package.json, we want to ensure that we use the correct version for the nuget - - task: PublishBuildArtifacts@1 - displayName: 'Publish updated package.json for nuget' - inputs: - PathtoPublish: 'vnext\package.json' - ArtifactName: 'UpdatedPackageJson' - - task: Npm@1 displayName: npm public publish (vnext) inputs: @@ -61,6 +55,8 @@ jobs: - job: RnwNativeBuild displayName: React-Native-Windows Native Build dependsOn: RnwNpmPublish + variables: + publishCommitId: $[ dependencies.RnwNpmPublish.outputs['updateVersionTask.publishCommitId'] ] strategy: matrix: X64Debug: @@ -90,13 +86,11 @@ jobs: steps: - # The RnwNpmPublish task does this too before publishing the npm package, - # but when each slice checks out code, its not going to have those changes + # Sync to point where the version numbers have been updated - task: CmdLine@2 - displayName: Update version numbers to align with publishing version inputs: - script: node ../.ado/bumpFileVersions.js - workingDirectory: vnext + script: git checkout $(publishCommitId) + - template: templates/npm-install-and-build.yml @@ -115,20 +109,23 @@ jobs: - job: RNWNuget - dependsOn: RnwNativeBuild + dependsOn: + - RnwNpmPublish + - RnwNativeBuild displayName: React-Native-Windows Build and Publish Nuget pool: name: OE Standard Pool + variables: + publishCommitId: $[ dependencies.RnwNpmPublish.outputs['updateVersionTask.publishCommitId'] ] + npmVersion: $[ dependencies.RnwNpmPublish.outputs['updateVersionTask.npmVersion'] ] + steps: - checkout: none #skip checking out the default repository resource - - task: DownloadBuildArtifacts@0 - displayName: 'Download source Artifact' - inputs: - artifactName: UpdatedPackageJson - downloadPath: $(System.DefaultWorkingDirectory) - - template: templates/prep-and-pack-nuget.yml + parameters: + publishCommitId: $(publishCommitId) + npmVersion: $(npmVersion) - task: NuGetCommand@2 displayName: 'NuGet push' diff --git a/.ado/templates/prep-and-pack-nuget.yml b/.ado/templates/prep-and-pack-nuget.yml index b7ce2fcb293..99044b6d87e 100644 --- a/.ado/templates/prep-and-pack-nuget.yml +++ b/.ado/templates/prep-and-pack-nuget.yml @@ -1,3 +1,6 @@ +parameters: + publishCommitId: '0' + npmVersion: '0.0.1-pr' steps: - task: DownloadBuildArtifacts@0 @@ -50,23 +53,12 @@ steps: robocopy $(System.DefaultWorkingDirectory)\ReactWindows-debug-arm $(System.DefaultWorkingDirectory)\NugetRoot\target\arm\debug /E /MOVE /NP robocopy $(System.DefaultWorkingDirectory)\ReactWindows-ship-arm $(System.DefaultWorkingDirectory)\NugetRoot\target\arm\ship /E /MOVE /NP - - task: PowerShell@2 - displayName: Extract version from package.json, and put it in nuspec - inputs: - targetType: inline # filePath | inline - script: | - if (Test-Path $env:SYSTEM_DEFAULTWORKINGDIRECTORY/UpdatedPackageJson/package.json) { - $lines = Get-Content $env:SYSTEM_DEFAULTWORKINGDIRECTORY/UpdatedPackageJson/package.json | Where {$_ -match '^\s*"version":.*'} - $npmVersion = $lines.Trim().Split()[1].Trim('",'); - } else { - $npmVersion = "0.0.1-pr" - } - (Get-Content $env:SYSTEM_DEFAULTWORKINGDIRECTORY/NugetRoot/ReactWin32.nuspec).replace('__BuildBuildNumber__', $npmVersion) | Set-Content $env:SYSTEM_DEFAULTWORKINGDIRECTORY/NugetRoot/ReactWin32.nuspec - (Get-Content $env:SYSTEM_DEFAULTWORKINGDIRECTORY/NugetRoot/ReactUwp.nuspec).replace('__BuildBuildNumber__', $npmVersion) | Set-Content $env:SYSTEM_DEFAULTWORKINGDIRECTORY/NugetRoot/ReactUwp.nuspec - - task: NuGetCommand@2 displayName: 'NuGet pack' inputs: command: pack packagesToPack: '$(System.DefaultWorkingDirectory)/NugetRoot/React*.nuspec' - packDestination: '$(System.DefaultWorkingDirectory)/NugetRoot/' \ No newline at end of file + packDestination: '$(System.DefaultWorkingDirectory)/NugetRoot/' + buildProperties: CommitId=$(publishCommitId) + versioningScheme: byEnvVar + versionEnvVar: npmVersion \ No newline at end of file diff --git a/.ado/updateVersion.js b/.ado/updateVersion.js index 970c278be2c..859d84f8ba5 100644 --- a/.ado/updateVersion.js +++ b/.ado/updateVersion.js @@ -65,6 +65,11 @@ function updateVersion() { exec(`git push origin HEAD:${tempPublishBranch} --follow-tags --verbose`); exec(`git push origin tag ${tagName}`); + // Record the updated npmVersion and commitId so that later build tasks can use it (to record in the nuget for instance) + const publishCommitId = execSync(`git rev-list -n 1 ${tagName}`); + console.log(`##vso[task.setvariable variable=publishCommitId;isOutput=true]${publishCommitId}`); + console.log(`##vso[task.setvariable variable=npmVersion;isOutput=true]${releaseVersion}`); + exec(`git checkout ${publishBranchName}`); exec(`git pull origin ${publishBranchName}`); exec(`git merge ${tempPublishBranch} --no-edit`); diff --git a/vnext/ReactUwp.nuspec b/vnext/ReactUwp.nuspec index e3aa48465e5..eb9afeabb45 100644 --- a/vnext/ReactUwp.nuspec +++ b/vnext/ReactUwp.nuspec @@ -7,6 +7,10 @@ Microsoft https://office.visualstudio.com/ISS/_git/sdx-platform false + MIT + diff --git a/vnext/ReactWin32.nuspec b/vnext/ReactWin32.nuspec index 30acf1d5007..5efad82931d 100644 --- a/vnext/ReactWin32.nuspec +++ b/vnext/ReactWin32.nuspec @@ -7,6 +7,10 @@ Microsoft https://office.visualstudio.com/ISS/_git/sdx-platform false + MIT + diff --git a/vnext/package.json b/vnext/package.json index 0686d256871..1e304ae7a59 100644 --- a/vnext/package.json +++ b/vnext/package.json @@ -13,7 +13,7 @@ "preinstall": "node Scripts/preInstall.js", "postinstall": "node Scripts/postInstall.js", "build": "just-scripts build", - "clean": "node Scripts/just.js clean", + "clean": "just-scripts clean", "start": "node Scripts/cli.js start", "watch": "node node_modules/@office-iss/sdx-build-tools/watch.js" }, From 4f75da04f5197f59a7f6bf54c892a770673bdbfa Mon Sep 17 00:00:00 2001 From: "REDMOND\\acoates" Date: Thu, 20 Jun 2019 09:37:07 -0700 Subject: [PATCH 2/5] Fix nuspec --- vnext/ReactUwp.nuspec | 1 - vnext/ReactWin32.nuspec | 1 - 2 files changed, 2 deletions(-) diff --git a/vnext/ReactUwp.nuspec b/vnext/ReactUwp.nuspec index eb9afeabb45..e37055abf13 100644 --- a/vnext/ReactUwp.nuspec +++ b/vnext/ReactUwp.nuspec @@ -7,7 +7,6 @@ Microsoft https://office.visualstudio.com/ISS/_git/sdx-platform false - MIT diff --git a/vnext/ReactWin32.nuspec b/vnext/ReactWin32.nuspec index 5efad82931d..3abe4c9e4d1 100644 --- a/vnext/ReactWin32.nuspec +++ b/vnext/ReactWin32.nuspec @@ -7,7 +7,6 @@ Microsoft https://office.visualstudio.com/ISS/_git/sdx-platform false - MIT From 2ff074248919df3d30303f67d74b3758499ee958 Mon Sep 17 00:00:00 2001 From: "REDMOND\\acoates" Date: Thu, 20 Jun 2019 13:07:07 -0700 Subject: [PATCH 3/5] commit id is only valid in nuget 4.6+ --- .ado/publish.yml | 5 +++++ .ado/templates/vs-build.yml | 2 +- .ado/windows-vs-pr.yml | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.ado/publish.yml b/.ado/publish.yml index 7d8b20ea182..3fcf1c341bc 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -122,6 +122,11 @@ jobs: steps: - checkout: none #skip checking out the default repository resource + # The commit tag in the nuspec requires that we use at least nuget 4.6 + - task: NuGetToolInstaller@0 + inputs: + versionSpec: '>=4.6.0' + - template: templates/prep-and-pack-nuget.yml parameters: publishCommitId: $(publishCommitId) diff --git a/.ado/templates/vs-build.yml b/.ado/templates/vs-build.yml index 273025ef7b6..2501c60cf67 100644 --- a/.ado/templates/vs-build.yml +++ b/.ado/templates/vs-build.yml @@ -14,7 +14,7 @@ steps: feedsToUse: config #vstsFeed: # Required when feedsToUse == Select #includeNuGetOrg: true # Required when feedsToUse == Select - nugetConfigPath: vnext/NuGet.config + nugetConfigPath: vnext/NuGet.config #externalFeedCredentials: # Optional #noCache: false #disableParallelProcessing: false diff --git a/.ado/windows-vs-pr.yml b/.ado/windows-vs-pr.yml index 7de3d672fb7..8227039782a 100644 --- a/.ado/windows-vs-pr.yml +++ b/.ado/windows-vs-pr.yml @@ -380,4 +380,9 @@ jobs: steps: - checkout: none #skip checking out the default repository resource + # The commit tag in the nuspec requires that we use at least nuget 4.6 + - task: NuGetToolInstaller@0 + inputs: + versionSpec: '>=4.6.0' + - template: templates/prep-and-pack-nuget.yml From 43e393f8b870e61764a076174556bd9b5185f1dc Mon Sep 17 00:00:00 2001 From: "REDMOND\\acoates" Date: Thu, 20 Jun 2019 14:04:38 -0700 Subject: [PATCH 4/5] Switch method of injecting version number --- .ado/templates/prep-and-pack-nuget.yml | 4 +--- vnext/ReactUwp.nuspec | 2 +- vnext/ReactWin32.nuspec | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.ado/templates/prep-and-pack-nuget.yml b/.ado/templates/prep-and-pack-nuget.yml index 99044b6d87e..744156c58a2 100644 --- a/.ado/templates/prep-and-pack-nuget.yml +++ b/.ado/templates/prep-and-pack-nuget.yml @@ -59,6 +59,4 @@ steps: command: pack packagesToPack: '$(System.DefaultWorkingDirectory)/NugetRoot/React*.nuspec' packDestination: '$(System.DefaultWorkingDirectory)/NugetRoot/' - buildProperties: CommitId=$(publishCommitId) - versioningScheme: byEnvVar - versionEnvVar: npmVersion \ No newline at end of file + buildProperties: CommitId=$(publishCommitId);npmVersion=$(npmVersion) \ No newline at end of file diff --git a/vnext/ReactUwp.nuspec b/vnext/ReactUwp.nuspec index e37055abf13..58c8eb21a22 100644 --- a/vnext/ReactUwp.nuspec +++ b/vnext/ReactUwp.nuspec @@ -2,7 +2,7 @@ OfficeReact.Uwp - __BuildBuildNumber__ + $npmVersion$ Contains Windows Implementation of React-Native Microsoft https://office.visualstudio.com/ISS/_git/sdx-platform diff --git a/vnext/ReactWin32.nuspec b/vnext/ReactWin32.nuspec index 3abe4c9e4d1..7e3a91ca12e 100644 --- a/vnext/ReactWin32.nuspec +++ b/vnext/ReactWin32.nuspec @@ -2,7 +2,7 @@ OfficeReact.Win32 - __BuildBuildNumber__ + $npmVersion$ Contains Windows Implementation of React-Native Microsoft https://office.visualstudio.com/ISS/_git/sdx-platform From 8754caa761d5bd9148d02e3904fca891b578c194 Mon Sep 17 00:00:00 2001 From: "REDMOND\\acoates" Date: Thu, 20 Jun 2019 15:15:42 -0700 Subject: [PATCH 5/5] Fix syntax of template variables --- .ado/templates/prep-and-pack-nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ado/templates/prep-and-pack-nuget.yml b/.ado/templates/prep-and-pack-nuget.yml index 744156c58a2..5a0ce0b1da3 100644 --- a/.ado/templates/prep-and-pack-nuget.yml +++ b/.ado/templates/prep-and-pack-nuget.yml @@ -59,4 +59,4 @@ steps: command: pack packagesToPack: '$(System.DefaultWorkingDirectory)/NugetRoot/React*.nuspec' packDestination: '$(System.DefaultWorkingDirectory)/NugetRoot/' - buildProperties: CommitId=$(publishCommitId);npmVersion=$(npmVersion) \ No newline at end of file + buildProperties: CommitId=${{parameters.publishCommitId}};npmVersion=${{parameters.npmVersion}} \ No newline at end of file