0.0.4 • Published 5 years ago

release-notifier v0.0.4

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

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<
  | {
      failures: string[];
    }
  | {}
>
0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago