Skip to content

Always release @firebase/app #4941

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

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Install Dependencies
run: yarn

- name: Add a changeset for @firebase/app
run: yarn ts-node-script scripts/add_changeset.ts

- name: Create Release Pull Request
uses: changesets/action@master
env:
Expand Down
68 changes: 68 additions & 0 deletions scripts/add_changeset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* @license
* Copyright 2021 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.
*/

/**
* Add a patch changeset for `@firebase/app` to force its release, so that
* the SDK_VERSION is up to date with the version of the umbrella package firebase.
*
* For background, see https://github.com/firebase/firebase-js-sdk/issues/4235
*/

import { writeFileSync } from 'fs';
import { projectRoot } from './utils';
import { exec } from 'child-process-promise';

const CONTENT = `
---
'@firebase/app': patch
---

Update SDK_VERSION.
`;

const FILE_PATH = `${projectRoot}/.changeset/bump-sdk-version.md`;

async function addChangeSet() {
// check if a few firebase version is being released
try {
const { stdout } = await exec('yarn changeset status');
// only add a changeset for @firebase/app if
// 1. we are publishing a new firebase version. and
// 2. @firebase/app is not already being published
const firebaseRelease = stdout.includes('- firebase\n');
const firebaseAppRelease = stdout.includes('- @firebase/app\n');
if (firebaseRelease && !firebaseAppRelease) {
console.log('Creating a patch changeset for @firebase/app');
writeFileSync(FILE_PATH, CONTENT, {
encoding: 'utf-8'
});
} else if (firebaseAppRelease) {
console.log(
'Skip creating a patch changeset for @firebase/app because it is already part of the release'
);
} else {
console.log(
'Skip creating a patch changeset for @firebase/app because firebase is not being released'
);
}
} catch (e) {
// log the error, the exit without creating a changeset
console.log('error:', e);
}
}

addChangeSet();