release-notifier

0.0.4 • Public • Published

release-notifier

Tool for notifying dependant projects when there is a new release.

Getting Started

Add this project to your repository.

yarn add release-notifier

Add .release-notifier to your .gitignore, release-notifier uses this folder to check out dependant projects and run scripts against them.

You may also wish to preserve this folder on ci to speed up release notificaions.

import { releaseNotifier } from 'release-notifier';
import { readFileSync } from 'fs';

const packageJson = require('./package.json);
const changelog = readFileSync('CHANGELOG.md', 'utf8');

const releaseVersion = packageJson.version;
const notificationTitle = `chore(bulb-icons): update to version ${releaseVersion}`;
const getNotificationMessage = (currentVersion) => `The `bulb-icons` project has an update available 🌈.

---

${getTrimmedChangelog(currentVersion)}
`;

const notifyDependendants = async () => {
    try {
        const releaseNotificationOutcome = await releaseNotifier({
            releaseVersion: packageJson.version,
            notificationTitle,
            notificationMessage,
            githubToken: 'GITHUB_ACCESS_TOKEN',
            githubDependants: [
                {
                    url: 'https://github.com/BulbEnergy/marketing',
                    branchToNotify: 'master',
                    releaseScriptPath: 'release-scripts/bulb-icons/index.js',
                },
            ],
        });

        if (typeof releaseNotificationOutcome.failures !== 'undefined') {
            console.error('Failed to notify dependants');

            console.error(releaseNotificationOutcome.failures);

            return;
        }

        console.log('succesfully notified dependant projects);
    } catch (err) {
        console.error('unknown error when updating dependants');

        throw err;
    }
}

notifyDependendants();

Options

export interface GithubDependant {
  url: string;
  /** path inside dependant project for custom release script */
  releaseScriptPath?: string;
}
 
export interface ReleaseNotifierOptions {
  dependency: string;
  releaseVersion: string;
  notificationTitle: string;
  getNotificationMessage: (options: { currentVersion: string }) => string;
  githubToken: string;
  githubDependants: GithubDependant[];
}
 
async (
  options: ReleaseNotifierOptions,
): Promise<
  | {
      failuresstring[];
    }
  | {}
>

Readme

Keywords

none

Package Sidebar

Install

npm i release-notifier

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

18.1 kB

Total Files

9

Last publish

Collaborators

  • luke-john