Skip to content

Commit ed9a7be

Browse files
authored
Use hash versions to publish exp packages (#2933)
* use sha version instead of semver * make firebase-exp private * Publish firebase@exp 0.800.1 * bump umbrella package version only * Publish firebase@exp 0.800.2 * restore package json * change prepare to use build:release * bump version correctly. * fix function name * [AUTOMATED]: Prettier Code Styling * update dep versions * correct typo * revert changes for debugging
1 parent d7c9ed4 commit ed9a7be

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

packages-exp/app-exp/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app-exp",
3-
"version": "0.800.0",
3+
"version": "0.0.800",
44
"private": true,
55
"description": "FirebaseApp",
66
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
@@ -29,7 +29,7 @@
2929
"build:doc": "yarn build && yarn doc"
3030
},
3131
"dependencies": {
32-
"@firebase/app-types-exp": "0.800.0",
32+
"@firebase/app-types-exp": "0.0.800",
3333
"@firebase/util": "0.2.44",
3434
"@firebase/logger": "0.2.1",
3535
"@firebase/component": "0.1.9",

packages-exp/app-types-exp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app-types-exp",
3-
"version": "0.800.0",
3+
"version": "0.0.800",
44
"private": true,
55
"description": "@firebase/app Types",
66
"author": "Firebase <[email protected]> (https://firebase.google.com/)",

packages-exp/firebase-exp/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "firebase-exp",
33
"version": "0.800.0",
4+
"private": true,
45
"description": "Firebase JavaScript library for web and Node.js",
56
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
67
"license": "Apache-2.0",
@@ -29,10 +30,10 @@
2930
"build": "rollup -c && gulp firebase-js",
3031
"build:release": "rollup -c rollup.config.release.js && gulp firebase-js",
3132
"dev": "rollup -c -w",
32-
"prepare": "yarn build"
33+
"prepare": "yarn build:release"
3334
},
3435
"dependencies": {
35-
"@firebase/app-exp": "0.800.0"
36+
"@firebase/app-exp": "0.0.800"
3637
},
3738
"devDependencies": {
3839
"rollup": "1.28.0",

scripts/exp/release.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const writeFile = promisify(_writeFile);
2929
const chalk = require('chalk');
3030
const Listr = require('listr');
3131

32+
const FIREBASE_UMBRELLA_PACKAGE_NAME = 'firebase-exp';
33+
3234
async function publishExpPackages() {
3335
try {
3436
/**
@@ -54,7 +56,7 @@ async function publishExpPackages() {
5456
/**
5557
* It does 2 things:
5658
*
57-
* 1. Bumps the patch version of exp packages regardless if there is any update
59+
* 1. Bumps the patch version of firebase-exp package regardless if there is any update
5860
* since the last release. This simplifies the script and works fine for exp packages.
5961
*
6062
* 2. Removes -exp in package names because we will publish them using
@@ -69,9 +71,17 @@ async function publishExpPackages() {
6971

7072
/**
7173
* reset the working tree to recover package names with -exp in the package.json files,
72-
* then bump patch version of all exp packages
74+
* then bump patch version of firebase-exp (the umbrella package) only
7375
*/
74-
await resetWorkingTreeAndBumpVersions(packagePaths, versions);
76+
const firebaseExpVersion = new Map();
77+
firebaseExpVersion.set(
78+
FIREBASE_UMBRELLA_PACKAGE_NAME,
79+
versions.get(FIREBASE_UMBRELLA_PACKAGE_NAME)
80+
);
81+
const firebaseExpPath = packagePaths.filter(p =>
82+
p.includes(FIREBASE_UMBRELLA_PACKAGE_NAME)
83+
);
84+
await resetWorkingTreeAndBumpVersions(firebaseExpPath, firebaseExpVersion);
7585

7686
/**
7787
* push to github
@@ -112,9 +122,18 @@ async function updatePackageNamesAndVersions(packagePaths) {
112122
const versions = new Map();
113123
for (const path of packagePaths) {
114124
const { version, name } = await readPackageJson(path);
115-
// increase the patch version of all exp packages
116-
const nextVersion = inc(version, 'patch');
117-
versions.set(name, nextVersion);
125+
126+
// increment firebase-exp's patch version
127+
if (name === FIREBASE_UMBRELLA_PACKAGE_NAME) {
128+
const nextVersion = inc(version, 'patch');
129+
versions.set(name, nextVersion);
130+
} else {
131+
// create individual packages version
132+
// we can't use minor version for them because most of them
133+
// are still in the pre-major version officially.
134+
const nextVersion = `${version}-exp.${await getCurrentSha()}`;
135+
versions.set(name, nextVersion);
136+
}
118137
}
119138

120139
await updatePackageJsons(packagePaths, versions, {
@@ -221,7 +240,7 @@ async function updatePackageJsons(
221240
async function commitAndPush(versions) {
222241
await exec('git add */package.json yarn.lock');
223242

224-
const firebaseExpVersion = versions.get('firebase-exp');
243+
const firebaseExpVersion = versions.get(FIREBASE_UMBRELLA_PACKAGE_NAME);
225244
await exec(
226245
`git commit -m "Publish firebase@exp ${firebaseExpVersion || ''}"`
227246
);
@@ -237,7 +256,7 @@ async function commitAndPush(versions) {
237256
}
238257

239258
function removeExpInPackageName(name) {
240-
const regex = /^(@firebase.*)-exp(.*)$/g;
259+
const regex = /^(.*firebase.*)-exp(.*)$/g;
241260

242261
const captures = regex.exec(name);
243262
if (!captures) {
@@ -255,4 +274,8 @@ async function readPackageJson(packagePath) {
255274
return JSON.parse(await readFile(`${packagePath}/package.json`, 'utf8'));
256275
}
257276

277+
async function getCurrentSha() {
278+
return (await git.revparse(['--short', 'HEAD'])).trim();
279+
}
280+
258281
publishExpPackages();

0 commit comments

Comments
 (0)