Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable changesets #3268

Merged
merged 28 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
83143e5
enable changeset
Feiyang1 May 19, 2020
4a514e2
Create release pull request
Feiyang1 May 19, 2020
ee7c9c6
change env variable name
Feiyang1 May 19, 2020
4b396ff
use the correct secret in GHA
Feiyang1 May 20, 2020
d94b627
make firebase a devDependency in integration test projects
Feiyang1 May 20, 2020
9283298
initial changeset release rewrite
Feiyang1 May 21, 2020
65d6be2
clean up imports in cli.ts
Feiyang1 May 21, 2020
53b1b94
save progress
Feiyang1 May 21, 2020
f3c0ba2
implement canary release
Feiyang1 May 29, 2020
c03cbff
update changesets to the latest
Feiyang1 Jun 20, 2020
ecaa9db
ignore integration test projects
Feiyang1 Jun 20, 2020
efb47b5
Merge branch 'master' into fei-changesets
Feiyang1 Jun 22, 2020
d873223
save updates
Feiyang1 Jun 23, 2020
4221ffa
update ignore list
Feiyang1 Jun 23, 2020
e613277
stream changeset output
Feiyang1 Jun 23, 2020
3164a1c
validate version for staging releases
Feiyang1 Jun 23, 2020
3ab3d59
fix bug
Feiyang1 Jun 23, 2020
23e8e62
add option
Feiyang1 Jun 23, 2020
1ded802
skip private packages
Feiyang1 Jun 24, 2020
059d5c2
remove unused things
Feiyang1 Jun 24, 2020
72c53f7
update release script
Feiyang1 Jun 24, 2020
086b5ed
Merge branch 'master' into fei-changesets
Feiyang1 Jun 24, 2020
b52c3bf
Merge remote-tracking branch 'origin/master' into fei-changesets
Feiyang1 Jun 24, 2020
b167bba
fix type errors
Feiyang1 Jun 24, 2020
74cb4c4
remove commented code
Feiyang1 Jun 24, 2020
f088bf5
fix types
Feiyang1 Jun 25, 2020
96949e5
add Changeset check
Feiyang1 Jun 25, 2020
f4a1c55
compare to master
Feiyang1 Jun 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md)
26 changes: 26 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "firebase/firebase-js-sdk"}],
"commit": false,
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": [
"firebase-browserify-test",
"firebase-package-typings-test",
"firebase-firestore-integration-test",
"firebase-messaging-selenium-test",
"firebase-typescript-test",
"firebase-webpack-test",
"@firebase/app-exp",
"@firebase/app-types-exp",
"@firebase/functions-exp",
"@firebase/functions-types-exp",
"firebase-exp"
],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true,
"useCalculatedVersionForSnapshots": true
}
}
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
push:
branches:
- release

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 12.x
uses: actions/setup-node@master
with:
node-version: 12.x

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request
uses: changesets/action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 1 addition & 3 deletions integration/browserify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"test": "karma start --single-run",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.15.4"
},
"devDependencies": {
"firebase": "7.15.4",
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"browserify": "16.5.1",
Expand Down
4 changes: 1 addition & 3 deletions integration/firebase-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
"test": "tsc",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.15.4"
},
"devDependencies": {
"firebase": "7.15.4",
"typescript": "3.8.3"
}
}
4 changes: 1 addition & 3 deletions integration/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"test": "mocha --exit",
"test:manual": "mocha --exit"
},
"dependencies": {
"firebase": "7.15.4"
},
"devDependencies": {
"firebase": "7.15.4",
"chai": "4.2.0",
"chromedriver": "^83.0.0",
"express": "4.17.1",
Expand Down
4 changes: 1 addition & 3 deletions integration/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
"test": "karma start --single-run",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.15.4"
},
"devDependencies": {
"firebase": "7.15.4",
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"@types/chai": "4.2.11",
Expand Down
4 changes: 1 addition & 3 deletions integration/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"test": "karma start --single-run",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.15.4"
},
"devDependencies": {
"firebase": "7.15.4",
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"chai": "4.2.0",
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"link:packages": "lerna exec --scope @firebase/* --scope firebase --scope rxfire -- yarn link",
"stage:packages": "./scripts/prepublish.sh",
"repl": "node tools/repl.js",
"release": "node scripts/release/cli.js",
"release": "ts-node-script scripts/release/cli.ts",
"pretest": "node tools/pretest.js",
"test": "lerna run --concurrency 4 --stream test",
"test:ci": "lerna run --concurrency 4 --stream test:ci",
Expand Down Expand Up @@ -60,17 +60,23 @@
"integration/*"
],
"devDependencies": {
"@changesets/changelog-github": "0.2.5",
"@changesets/cli": "2.9.1",
"@microsoft/api-documenter": "7.7.20",
"@microsoft/api-extractor": "7.7.13",
"@types/chai": "4.2.11",
"@types/chai-as-promised": "7.1.2",
"@types/child-process-promise": "2.2.1",
"@types/clone": "0.1.30",
"@types/inquirer": "6.5.0",
"@types/long": "4.0.1",
"@types/mocha": "7.0.2",
"@types/node": "12.12.37",
"@types/sinon": "9.0.0",
"@types/sinon-chai": "3.2.4",
"@types/tmp": "0.2.0",
"@types/yargs": "15.0.4",
"@types/listr": "0.14.2",
"@typescript-eslint/eslint-plugin": "2.30.0",
"@typescript-eslint/eslint-plugin-tslint": "2.30.0",
"@typescript-eslint/parser": "2.30.0",
Expand Down
5 changes: 2 additions & 3 deletions scripts/emulator-testing/database-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ import { spawn } from 'child-process-promise';
import * as path from 'path';

import { DatabaseEmulator } from './emulators/database-emulator';
import { ChildProcessPromise } from './emulators/emulator';

function runTest(port: number, namespace: string): ChildProcessPromise {
function runTest(port: number, namespace: string) {
const options = {
cwd: path.resolve(__dirname, '../../packages/database'),
env: Object.assign({}, process.env, {
RTDB_EMULATOR_PORT: port,
RTDB_EMULATOR_NAMESPACE: namespace
}),
stdio: 'inherit'
stdio: 'inherit' as const
};
return spawn('yarn', ['test:all'], options);
}
Expand Down
13 changes: 7 additions & 6 deletions scripts/emulator-testing/emulators/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import * as request from 'request';
// @ts-ignore
import * as tmp from 'tmp';

export interface ChildProcessPromise extends Promise<void> {
childProcess: ChildProcess;
}

export abstract class Emulator {
binaryPath: string | null = null;
emulator: ChildProcess | null = null;
Expand Down Expand Up @@ -72,9 +68,14 @@ export abstract class Emulator {
if (!this.binaryPath) {
throw new Error('You must call download() before setUp()');
}
const promise: ChildProcessPromise = spawn(
const promise = spawn(
'java',
['-jar', path.basename(this.binaryPath), '--port', this.port],
[
'-jar',
path.basename(this.binaryPath),
'--port',
this.port.toString()
],
{
cwd: path.dirname(this.binaryPath),
stdio: 'inherit'
Expand Down
153 changes: 153 additions & 0 deletions scripts/release/canary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { getCurrentSha } from './utils/git';
import {
getAllPackages,
mapPkgNameToPkgJson,
updateWorkspaceVersions,
mapPkgNameToPkgPath
} from './utils/workspace';
import Listr from 'listr';
import { readFile as _readFile } from 'fs';
import { promisify } from 'util';
import { exec, spawn } from 'child-process-promise';
import { buildPackages } from './utils/yarn';

const readFile = promisify(_readFile);

/**
*
* NOTE: Canary releases are performed in CI.
* Canary release does NOT do the following compared to a regular release:
* - Commit/Tag the release (we aren't creating new tags, just exposing the
* current version)
* - Push updates to github (no updates to push)
*/
export async function runCanaryRelease(): Promise<void> {
/**
* Set the canary version following the pattern below:
*
* Version: <version>-canary.<git sha>
*
* A user would be able to install a package canary as follows:
*
* $ npm install @firebase/app@canary
*/
const sha = await getCurrentSha();
const updates = await getAllPackages();
const pkgJsons = await Promise.all(
updates.map(pkg => mapPkgNameToPkgJson(pkg))
);
const versions = pkgJsons.reduce<{ [key: string]: string }>(
(map, pkgJson) => {
const { version, name } = pkgJson;
map[name] = `${version}-canary.${sha}`;
return map;
},
{}
);

/**
* Update the package.json dependencies throughout the SDK
*/
await updateWorkspaceVersions(versions, true);

/**
* build packages
*/
await buildPackages();

await publishToNpm(updates);
}

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

async function publishPackage(pkg: string) {
try {
const path = await mapPkgNameToPkgPath(pkg);

const { private: isPrivate } = JSON.parse(
await readFile(`${path}/package.json`, 'utf8')
);

/**
* Skip private packages
*/
if (isPrivate) return;

/**
* publish args
*/
const args = [
'publish',
'--access',
'public',
'--tag',
'canary',
'--registry',
'https://wombat-dressing-room.appspot.com'
];

// Write proxy registry token for this package to .npmrc.
await exec(
`echo "//wombat-dressing-room.appspot.com/:_authToken=${
process.env[getEnvTokenKey(pkg)]
}" >> ~/.npmrc`
);

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

async function publishToNpm(updatedPkgs: string[]) {
const taskArray = await Promise.all(
updatedPkgs.map(async pkg => {
const path = await mapPkgNameToPkgPath(pkg);

/**
* Can't require here because we have a cached version of the required JSON
* in memory and it doesn't contain the updates
*/
const { version } = JSON.parse(
await readFile(`${path}/package.json`, 'utf8')
);
return {
title: `📦 ${pkg}@${version}`,
task: () => publishPackage(pkg)
};
})
);
const tasks = new Listr(taskArray, {
concurrent: false,
exitOnError: false
});

console.log('\r\nPublishing Packages to NPM:');
return tasks.run();
}
Loading