Skip to content

Commit

Permalink
Introduce yarn workspace, and use beachball for publishing (#2805)
Browse files Browse the repository at this point in the history
* Add yarn workspace and an additional package -- and start hooking up beachball

* update lock

* Dont allow patch changes on react-native-windows

* Change files

* Fix publish pipeline to work with beachball

* UWP build needs to run yarn from root.

* Simplify our custom rn-cli.config
  • Loading branch information
acoates-ms authored and msftbot[bot] committed Jul 24, 2019
1 parent d21daea commit 407c083
Show file tree
Hide file tree
Showing 29 changed files with 3,281 additions and 668 deletions.
7 changes: 7 additions & 0 deletions .ado/evergreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,19 @@ request.get('https://raw.githubusercontent.com/microsoft/react-native/master/pac
existingPkgJson.peerDependencies['react-native'] = rnDependency;
existingPkgJson.devDependencies['react-native'] = pkgJson.version;

const rnwePkgJsonPath = path.resolve(__dirname, '../packages/react-native-windows-extended/package.json');
let rnwePkgJson = JSON.parse(fs.readFileSync(rnwePkgJsonPath, 'utf8'));
rnwePkgJson.peerDependencies['react-native'] = rnDependency;
rnwePkgJson.devDependencies['react-native'] = pkgJson.version;

branchName = branchNamePrefix + sanitizeBranchName(pkgJson.version);

exec(`npm install -g yarn`);

exec(`git checkout -b ${branchName} --track origin/${finalTargetBranchName}`);
exec(`git pull`);
fs.writeFileSync(pkgJsonPath, JSON.stringify(existingPkgJson, null, 2));
fs.writeFileSync(rnwePkgJsonPath, JSON.stringify(rnwePkgJson, null, 2));

process.chdir(path.resolve(__dirname, '../vnext'));

Expand All @@ -175,6 +181,7 @@ request.get('https://raw.githubusercontent.com/microsoft/react-native/master/pac

exec(`git add ${path.resolve(__dirname, '../vnext/yarn.lock')}`);
exec(`git add ${pkgJsonPath}`);
exec(`git add ${rnwePkgJsonPath}`)
exec(`git commit -m "Update to react-native@${pkgJson.version}"`);
exec(`git push origin ${branchName}`);

Expand Down
46 changes: 31 additions & 15 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ trigger:
include:
- vnext/*
exclude:
- change/*
- vnext/package.json
- vnext/yarn.lock
- vnext/Desktop.DLL/Version.rc
Expand All @@ -37,21 +38,23 @@ jobs:
- template: templates/npm-install-and-build.yml

- task: CmdLine@2
displayName: Update package version
name: updateVersionTask
displayName: Beachball Publish (for master)
inputs:
script: node ../.ado/updateVersion.js
script: node ./node_modules/beachball/bin/beachball.js publish --tag vnext
workingDirectory: vnext
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))

- task: Npm@1
displayName: npm public publish (vnext)
- task: CmdLine@2
displayName: Beachball Publish (for other branches)
inputs:
script: node ./node_modules/beachball/bin/beachball.js publish --tag $(Build.SourceBranchName) -n $(npmAuthToken) -y
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'master'))

- task: CmdLine@2
displayName: Set Version Env Vars
name: setVersionEnvVars
inputs:
command: custom
workingDir: vnext
verbose: false
customCommand: publish --access public --tag $(npmTag)
customEndpoint: 'React-Native-Windows NPM'
publishEndpoint: 'React-Native-Windows NPM'
script: node ../.ado/setVersionEnvVars.js

- job: RnwNativeBuild
displayName: React-Native-Windows Native Build
Expand Down Expand Up @@ -92,13 +95,27 @@ jobs:
inputs:
script: git checkout $(publishCommitId)


- template: templates/npm-install-and-build.yml

# Update version numbers as will be done by npm publish
- task: CmdLine@2
displayName: Beachball bump
inputs:
script: node ./node_modules/beachball/bin/beachball.js bump
workingDirectory: vnext
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))

- task: CmdLine@2
displayName: Set Version Env Vars
name: setVersionEnvVars
inputs:
script: node ../.ado/setVersionEnvVars.js

- template: templates/vs-build.yml
parameters:
BuildConfiguration: $(BuildConfiguration)
BuildPlatform: $(BuildPlatform)
env: { RNW_PKG_VERSION_STR: $(RNW_PKG_VERSION_STR), RNW_PKG_VERSION:$(RNW_PKG_VERSION) }

- template: templates/publish-build-artifacts-for-nuget.yml

Expand All @@ -117,8 +134,7 @@ jobs:
pool:
name: OE Standard Pool
variables:
publishCommitId: $[ dependencies.RnwNpmPublish.outputs['updateVersionTask.publishCommitId'] ]
npmVersion: $[ dependencies.RnwNpmPublish.outputs['updateVersionTask.npmVersion'] ]
npmVersion: $[ dependencies.RnwNpmPublish.outputs['setVersionEnvVars.npmVersion'] ]

steps:
- checkout: none #skip checking out the default repository resource
Expand All @@ -130,7 +146,7 @@ jobs:

- template: templates/prep-and-pack-nuget.yml
parameters:
publishCommitId: $(publishCommitId)
publishCommitId: $(Build.SourceVersion)
npmVersion: $(npmVersion)

- task: NuGetCommand@2
Expand Down
24 changes: 24 additions & 0 deletions .ado/setVersionEnvVars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check
const fs = require("fs");
const path = require("path");

const pkgJsonPath = path.resolve(__dirname, "../vnext/package.json");

// Helper to format npmVersion in a way that the Version.rc resource files want it
function npmVersionToRcVersion(npmVersion) {
let groups = npmVersion.split(/[\.-]/);
return `${groups[0]},${groups[1]},${groups[2]},${groups[4]}`;
}

let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));

// Set env variable to allow VS to build dll with correct version information
console.log(
`##vso[task.setvariable variable=RNW_PKG_VERSION_STR]${pkgJson.version}`
);
// Set env variable to allow VS to build dll with correct version information
console.log(
`##vso[task.setvariable variable=RNW_PKG_VERSION]${npmVersionToRcVersion(pkgJson.version)}`
);

console.log(`##vso[task.setvariable variable=npmVersion;isOutput=true]${pkgJson.version}`);
83 changes: 0 additions & 83 deletions .ado/updateVersion.js

This file was deleted.

82 changes: 0 additions & 82 deletions .ado/versionUtils.js

This file was deleted.

5 changes: 0 additions & 5 deletions .ado/windows-vs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ jobs:
displayName: yarn install (Using microsoft/react-native)
inputs:
script: yarn install --frozen-lockfile
workingDirectory: vnext
condition: and(succeeded(), eq(variables['UseRNFork'], 'true'))

# We can't use a frozen lockfile for both the fork and non-fork, since they install different dependencies
Expand All @@ -71,7 +70,6 @@ jobs:
displayName: yarn install (Using facebook/react-native)
inputs:
script: yarn install
workingDirectory: vnext
condition: and(succeeded(), eq(variables['UseRNFork'], 'false'))

- template: templates/stop-packagers.yml
Expand Down Expand Up @@ -158,7 +156,6 @@ jobs:
displayName: yarn install (local react-native-windows)
inputs:
script: yarn install --frozen-lockfile
workingDirectory: vnext

- task: CmdLine@2
displayName: yarn build (local react-native-windows)
Expand Down Expand Up @@ -261,7 +258,6 @@ jobs:
displayName: yarn install
inputs:
script: yarn install --frozen-lockfile
workingDirectory: vnext

- template: templates/stop-packagers.yml

Expand Down Expand Up @@ -368,7 +364,6 @@ jobs:
displayName: yarn install
inputs:
script: yarn install --frozen-lockfile
workingDirectory: vnext

- task: CmdLine@2
displayName: yarn format:verify
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ packages/
*.nuget.props
*.nuget.targets

#Allow root packages folder though
!/packages


#ncrunch
*ncrunch*
*crunch*.local.xml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"comment": "Hookup beachball for publishing",
"type": "prerelease",
"packageName": "react-native-windows",
"email": "[email protected]",
"commit": "a0e9f6710d762a92d67a40c939dffa52914130b2",
"date": "2019-07-18T19:30:50.792Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"comment": "Initial commit",
"type": "patch",
"packageName": "react-native-windows-extended",
"email": "[email protected]",
"commit": "a0e9f6710d762a92d67a40c939dffa52914130b2",
"date": "2019-07-18T19:30:30.735Z"
}
3 changes: 3 additions & 0 deletions current/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@
},
"plugin": "./local-cli/index.js",
"platform": "./local-cli/platform.js"
},
"beachball": {
"shouldPublish": false
}
}
Loading

0 comments on commit 407c083

Please sign in to comment.