Skip to content

Commit 39ce8a7

Browse files
authored
Use $buildNumber$ token for NuGet (#198)
* Use Nuget token for versions * Use NuGet v4.6.4+ * Add buildProps during Android PR
1 parent 99e819f commit 39ce8a7

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.ado/android-pr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
- task: UseNode@1
2525
inputs:
2626
version: '10.x'
27+
28+
# Install NuGet v4.6.4+
29+
- task: NuGetToolInstaller@1
30+
inputs:
31+
versionSpec: '>=4.6.4'
2732

2833
- task: CmdLine@2
2934
displayName: npm install
@@ -112,6 +117,7 @@ jobs:
112117
command: pack
113118
packagesToPack: 'ReactAndroid/ReactAndroid.nuspec'
114119
packDestination: '$(System.DefaultWorkingDirectory)'
120+
buildProperties: buildNumber=$(buildNumber);commitId=$(Build.SourceVersion)
115121

116122
- task: Gradle@1
117123
displayName: gradlew clean

.ado/publish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
2929
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch
3030

31+
# Install NuGet v4.6.4+
32+
- task: NuGetToolInstaller@1
33+
inputs:
34+
versionSpec: '>=4.6.4'
35+
3136
- task: CmdLine@2
3237
displayName: npm install
3338
inputs:
@@ -110,6 +115,7 @@ jobs:
110115
command: pack
111116
packagesToPack: 'ReactAndroid/ReactAndroid.nuspec'
112117
packDestination: '$(Build.StagingDirectory)\final'
118+
buildProperties: buildNumber=$(buildNumber);commitId=$(Build.SourceVersion)
113119

114120
- task: CmdLine@2
115121
displayName: Do Publish

.ado/templates/prep-android-nuget.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
steps:
22
- task: PowerShell@2
3-
displayName: Extract version from package.json, and put it in nuspec
3+
displayName: Extract version from package.json, and put it in `buildNumber` variable
44
inputs:
55
targetType: inline # filePath | inline
66
script: |
77
$lines = Get-Content package.json | Where {$_ -match '^\s*"version":.*'}
88
$npmVersion = $lines.Trim().Split()[1].Trim('",');
9-
(Get-Content ReactAndroid/ReactAndroid.nuspec).replace('__BuildBuildNumber__', $npmVersion) | Set-Content ReactAndroid/ReactAndroid.nuspec
9+
echo "##vso[task.setvariable variable=buildNumber]$npmVersion"
1010
1111
# Pretty yucky - but we dont want devmain to have to update versions _all_ over the place
1212
- task: PowerShell@2

ReactAndroid/ReactAndroid.nuspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>OfficeReact.Android</id>
5-
<version>__BuildBuildNumber__</version>
5+
<version>$buildNumber$</version>
66
<description>Contains Android Implementation of React-Native</description>
77
<authors>Microsoft</authors>
88
<projectUrl>https://github.com/microsoft/react-native</projectUrl>
9+
<repository type="git" url="https://github.com/microsoft/react-native.git" commit="$commitId$" />
910
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1011
</metadata>
1112

0 commit comments

Comments
 (0)