Skip to content

Commit

Permalink
Set canary publish to use wombot (#2690)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Mar 6, 2020
1 parent 48e6271 commit 43c67ac
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
41 changes: 34 additions & 7 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,41 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 10.x
registry-url: 'https://registry.npmjs.org'
- name: Yarn install
run: yarn
- name: yarn build
run: yarn build
- name: Deploy canary
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
yarn release --canary
run: yarn release --canary
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_TOKEN_ANALYTICS: ${{secrets.NPM_TOKEN_ANALYTICS}}
NPM_TOKEN_ANALYTICS_INTEROP_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_INTEROP_TYPES}}
NPM_TOKEN_ANALYTICS_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_TYPES}}
NPM_TOKEN_APP: ${{secrets.NPM_TOKEN_APP}}
NPM_TOKEN_APP_TYPES: ${{secrets.NPM_TOKEN_APP_TYPES}}
NPM_TOKEN_AUTH: ${{secrets.NPM_TOKEN_AUTH}}
NPM_TOKEN_AUTH_INTEROP_TYPES: ${{secrets.NPM_TOKEN_AUTH_INTEROP_TYPES}}
NPM_TOKEN_AUTH_TYPES: ${{secrets.NPM_TOKEN_AUTH_TYPES}}
NPM_TOKEN_COMPONENT: ${{secrets.NPM_TOKEN_COMPONENT}}
NPM_TOKEN_DATABASE: ${{secrets.NPM_TOKEN_DATABASE}}
NPM_TOKEN_DATABASE_TYPES: ${{secrets.NPM_TOKEN_DATABASE_TYPES}}
NPM_TOKEN_FIRESTORE: ${{secrets.NPM_TOKEN_FIRESTORE}}
NPM_TOKEN_FIRESTORE_TYPES: ${{secrets.NPM_TOKEN_FIRESTORE_TYPES}}
NPM_TOKEN_FUNCTIONS: ${{secrets.NPM_TOKEN_FUNCTIONS}}
NPM_TOKEN_FUNCTIONS_TYPES: ${{secrets.NPM_TOKEN_FUNCTIONS_TYPES}}
NPM_TOKEN_INSTALLATIONS: ${{secrets.NPM_TOKEN_INSTALLATIONS}}
NPM_TOKEN_INSTALLATIONS_TYPES: ${{secrets.NPM_TOKEN_INSTALLATIONS_TYPES}}
NPM_TOKEN_LOGGER: ${{secrets.NPM_TOKEN_LOGGER}}
NPM_TOKEN_MESSAGING: ${{secrets.NPM_TOKEN_MESSAGING}}
NPM_TOKEN_MESSAGING_TYPES: ${{secrets.NPM_TOKEN_MESSAGING_TYPES}}
NPM_TOKEN_PERFORMANCE: ${{secrets.NPM_TOKEN_PERFORMANCE}}
NPM_TOKEN_PERFORMANCE_TYPES: ${{secrets.NPM_TOKEN_PERFORMANCE_TYPES}}
NPM_TOKEN_POLYFILL: ${{secrets.NPM_TOKEN_POLYFILL}}
NPM_TOKEN_REMOTE_CONFIG: ${{secrets.NPM_TOKEN_REMOTE_CONFIG}}
NPM_TOKEN_REMOTE_CONFIG_TYPES: ${{secrets.NPM_TOKEN_REMOTE_CONFIG_TYPES}}
NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}}
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
NPM_TOKEN_RXFIRE: ${{secrets.NPM_TOKEN_RXFIRE}}
CI: true
6 changes: 4 additions & 2 deletions scripts/release/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ const { argv } = require('yargs');
/**
* Log the user who will be publishing the packages
*/
const { stdout: whoami } = await exec('npm whoami');
console.log(`Publishing as ${whoami}`);
if (!process.env.CI) {
const { stdout: whoami } = await exec('npm whoami');
console.log(`Publishing as ${whoami}`);
}

/**
* Determine if the current release is a staging or production release
Expand Down
24 changes: 21 additions & 3 deletions scripts/release/utils/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@
*/

const { projectRoot: root } = require('./constants');
const { spawn } = require('child-process-promise');
const { spawn, exec } = require('child-process-promise');
const { mapPkgNameToPkgPath } = require('./workspace');
const { readFile: _readFile } = require('fs');
const { promisify } = require('util');
const Listr = require('listr');
const readFile = promisify(_readFile);

/**
* Given NPM package name, get env variable name for its publish token.
* @param {string} packageName NPM package name
*/
function getEnvTokenKey(packageName) {
let result = packageName.replace('@firebase/', '');
result = result.replace(/-/g, '_');
result = result.toUpperCase();
return `NPM_TOKEN_${result}`;
}

async function publishPackage(pkg, releaseType) {
try {
const path = await mapPkgNameToPkgPath(pkg);
Expand All @@ -48,9 +59,16 @@ async function publishPackage(pkg, releaseType) {
if (releaseType === 'Staging') {
args = [...args, '--tag', 'next'];
} else if (releaseType === 'Canary') {
args = [...args, '--tag', 'canary'];
// Write proxy registry token for this package to .npmrc.
await exec(`echo "//wombat-dressing-room.appspot.com/:_authToken=${process.env[getEnvTokenKey(pkg)]}" >> ~/.npmrc`);
args = [
...args,
'--tag',
'canary',
'--registry',
`https://wombat-dressing-room.appspot.com`
];
}

return spawn('npm', args, { cwd: path });
} catch (err) {
throw err;
Expand Down

0 comments on commit 43c67ac

Please sign in to comment.