dripip
Opinionated CLI for continuous delivery of npm packages
Last updated a month ago by jasonkuhrt .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install dripip 
SYNC missed versions from official npm registry.

ci/cd

dripip

Opinionated CLI for continuous delivery of npm packages.

Installation

npm install --save-dev dripip

Overview

diagram

Dripip is a command line interface (CLI) for continuously releasing npm packages. It has support for three kinds of releases: pull-request releases, canary releases, stable releases. It builds on top of Git, Semver, Conventional Commit, and GitHub. Support for alterntive version control systems (e.g. Darcs) and platforms (e.g. GitLab) are not currently supported but they probably could be. The concepts of dripip are relatively general.

Continuous delivery means that every single meaningful commit to your library will be released. The benefit of this approach is that when you ship value your users get access to it immeditely, and as an author you don't need to manage incoming queries like "when will this be released?". You get to to auto-reply: "It already it! :)".

Pull-Request Releases

Pull-request releases occur on, surprise, pull-requests. You can have CI run them or do them ad-hoc from your machine, either workflow is fine (but choose one, as mixing will naturally lead to already-published errors). These kinds of releases are useful when link workflows are not good enough. For example your feature is a CLI that you want to make sure plays well with npx. Unlike other release types pull-request releases do not result in git tags. Instead, Dripip uses the npm registry to maintain its release state. The version pattern of a pull-request release is:

0.0.0-pr.${pr_num}.${pr_release_num}.${short_sha}

For example:

0.0.0-pr.45.4.9a3b2c1

The 0.0.0 version is used because there is no meaningful semantic version to put here. It cannot be the version you're branching from since this version syntax would indicate it is a pre-release for that version, which it isn't, it's the opposite, a release after it; It cannot be the version you're going towards because it cannot be generally known if a PR will result in a patch minor or major semver change; Even if Dripip tried to apply conventional commit analysis to the PR commits it wouldn't account for concurrent PRs and the generally async nature that PRs live in with regard to one another. So ultimately 0.0.0 is the most sensible general choice.

The pr_num part is the pull-request number. The same one that you see on the GitHub UI, URL etc. of a pull-request.

The pr_release_num is a monotonically increasing 1-based (starts from 1, not 0) integer. It serves a few purposes. It provides orientation for humans at a glance, like how many releases has a PR had or where does a given release fall within the PR release set. Its functional purpose is to support correct lexical sorting. Without this little number it would be impossible to sort PR releases without some kind of additional metadata e.g. publish time. Thanks to this, when you run e.g. npm versions, you get an accurate ordering.

The short_sha is what you see next to commits in much of the GitHub UI, including PR pages. Its primary purpose is to make it easy for you to tie a release back to something in your Git history. For example when looking at a PR page you can copy-paste the sha into search to find the exact commit for that release. Whatever the particular, this is just a convenient piece of information for you. Ultimately we develoeprs pratice many a crude workflow, habbits (console.log vs debugger anyone?).

When Dripip makes a pr release, it includes an upsert of a dist-tag of pattern pr.${pr_num}. This makes it very easy to install the latest published version for a given pull-request.

Canary Releases

Canary releases occur on trunk branches. These releases should be automated by your CI. They give your users access to what your stable version will become. The version pattern of a canary release is:

${next_stable}-next.${series_release_num}

For example:

1.2.0-next.4

The next_stable is whatever your upcoming stable version will be. The series_release_num is a monotonically increasing 1-based (starts from 1, not 0) integer. The first canary release after a stable release starts at 1, increasing by 1 at each canary release, until a stable is cut at which point the numbering is reset upon the next canary release.

When Dripip makes a canary release, it includes an upsert of a dist-tag called next. This makes it very easy to install the bleeding edge of your package. Additionally, a git tag called next is also maintained. Whatever commit the next tag is on is the same instance of your package that would be installed if a user did npm install <your package>@next.

Stable Releases

Stable releases occur on trunk branches. The version pattern of a stable release is just a regular version, whatever the next stable is:

${next_stable}

For example:

1.2.0

These releases should be managed however your team works, of course, but here are some general tips:

  • Think very carefully before automating stable releases. You need to have very very high confidence in your/your team's git commit message practices to take this route. One wrong BREAKING CHANGE line can be all it takes to make an accidental major release that npm won't allow you to undo (unless you catch very quickly).
  • Releases on a cadence, such as every week or two, either manually or by automation, is often a good way to go.
  • Do not publish stables too often. It dillutes their meaningfulness and creates churn for users of tools like Renovate and Dependabot. Its probably better for your users to get one semi-exciting PR to update their dep on your package once every week or two than once a day! This approach also plays better with the GitHub releases UI where only a handful of releases are rendered for every page and even less visible without scrolling.

When Dripip makes a canary release, it includes an upsert of a dist-tag called latest. This is actually what npm already does by default. Dripip does not deviate here.

Package.json Version Field

Typically when an npm package is released its package.json version field will be updated and committed into version control. This is a bad match for continuous delivery however, because it meanss that, more or less, half of the git history will become meta commits. To solve this, dripip takes a novel approach of keeping the version out of version control. It uses Git tags to store that state, and when publishing your package, will set the package.json version field right before publishing, and then unset it right after publishing completes. You notice nothing, your users notice nothing, and your git history looks ideal. This is unorthadox, but it works well.

Having a valid semver value in the version field is required by npm. Dripip puts the following value into your project's package.json to satisfy that constraint. This is what you should check into version control.

0.0.0-dripip

Release Notes (aka. Changelogs)

Dripip generates release notes for canary and stable releases. Notes are published within GitHub releases. Canary release notes are published under the next tag. Stable release notes are published under its respective version tag. Stable release notes are stable, while Canary release notes are always changing. When a stable release is cut, the canary release notes are cleared since next becomes the same as stable, until the next Canary is published.

Because the canary release notes have a stable tag, it means you and your uses can always check out what's coming in the next stable version by visiting:

https://github.com/<org>/<repo>/releases/tag/next

For example checkout what's coming up in dripip right now by visiting https://github.com/prisma-labs/dripip/releases/tag/next.

Recipes

Usage inside GitHub Actions

We are interseted in building a dripip GitHub Action. Until it ships, here are the things you need to do.

  1. Have dripip installed as a dev dependency
  2. Upload an NPM_TOKEN to your repo (gh docs)
  3. Expose GITHUB_TOKEN to dripip (gh docs)
  4. Expose NPM_TOKEN to dripip
  5. Checkout all repo commits and tags

Example Workflow Configuration:

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Get all git commits and tags
        run: git fetch --prune --unshallow --tags
      - uses: actions/setup-node@v1
      - run: yarn --frozen-lockfile
      - run: yarn -s dripip preview-or-pr
        env:
          NPM_TOKEN: ${{secrets.NPM_TOKEN}}
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Real World Usage:

CLI

dripip get-current-commit-version

USAGE
  $ dripip get-current-commit-version

OPTIONS
  -r, --optional  Exit 0 if a version for the commit cannot be found

See code: dist/cli/commands/get-current-commit-version.ts

dripip get-current-pr-num

USAGE
  $ dripip get-current-pr-num

OPTIONS
  -r, --optional  Exit 0 if a pr number cannot be found for whatever reason

See code: dist/cli/commands/get-current-pr-num.ts

dripip help [COMMAND]

display help for dripip

USAGE
  $ dripip help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

dripip log

USAGE
  $ dripip log

OPTIONS
  -j, --json      format output as JSON
  -m, --markdown  format output as Markdown

See code: dist/cli/commands/log.ts

dripip pr

USAGE
  $ dripip pr

OPTIONS
  -d, --dry-run  output what the next version would be if released now
  -j, --json     format output as JSON

dripip preview

USAGE
  $ dripip preview

OPTIONS
  -d, --dry-run              output what the next version would be if released now
  -j, --json                 format output as JSON
  -n, --build-num=build-num  Force a build number. Should not be needed generally. For exceptional cases.
  --skip-npm                 skip the step of publishing the package to npm

  --trunk=trunk              State which branch is trunk. Defaults to honuring the "base" branch setting in the GitHub
                             repo settings.

dripip preview-or-pr

USAGE
  $ dripip preview-or-pr

See code: dist/cli/commands/preview-or-pr.ts

dripip stable

USAGE
  $ dripip stable

OPTIONS
  -d, --dry-run  output what the next version would be if released now
  -j, --json     format output as JSON
  --skip-npm     skip the step of publishing the package to npm

  --trunk=trunk  State which branch is trunk. Defaults to honuring the "base" branch setting in the GitHub repo
                 settings.

Current Tags

  • 0.9.0                                ...           latest (a month ago)
  • 0.9.0                                ...           next (a month ago)
  • 0.0.0-pr.30.3.685ba37                                ...           pr.30 (3 months ago)
  • 0.0.0-pr.43.2.53af09d                                ...           pr.43 (3 months ago)
  • 0.0.0-pr.45.2.e5796fc                                ...           pr.45 (3 months ago)
  • 0.0.0-pr.47.1.805964d                                ...           pr.47 (3 months ago)
  • 0.0.0-pr.49.1.9fb5e42                                ...           pr.49 (3 months ago)
  • 0.0.0-pr.50.3.b1d9bc4                                ...           pr.50 (3 months ago)
  • 0.0.0-pr.53.3.0a8f84f                                ...           pr.53 (3 months ago)
  • 0.0.0-pr.54.1.8450677                                ...           pr.54 (2 months ago)
  • 0.0.0-pr.59.20.fdd781e                                ...           pr.59 (2 months ago)
  • 0.0.0-pr.60.1.67c6bbe                                ...           pr.60 (2 months ago)
  • 0.0.0-pr.61.2.9c2f427                                ...           pr.61 (2 months ago)
  • 0.0.0-pr.62.4.7a1da7b                                ...           pr.62 (2 months ago)
  • 0.0.0-pr.63.1.1551ddd                                ...           pr.63 (2 months ago)
  • 0.0.0-pr.64.1.d17b6a8                                ...           pr.64 (2 months ago)
  • 0.0.0-pr.66.5.1866785                                ...           pr.66 (a month ago)
  • 0.0.0-pr.67.1.29c0576                                ...           pr.67 (a month ago)
  • 0.0.0-pr.68.14.6e55a86                                ...           pr.68 (a month ago)
  • 0.0.0-pr.69.1.a82de72                                ...           pr.69 (a month ago)
  • 0.0.0-pr.70.1.5a0d2d1                                ...           pr.70 (a month ago)

120 Versions

  • 0.9.0                                ...           a month ago
  • 0.9.0-next.11                                ...           a month ago
  • 0.9.0-next.10                                ...           a month ago
  • 0.0.1-next.11                                ...           a month ago
  • 0.0.1-next.10                                ...           a month ago
  • 0.9.0-next.9                                ...           a month ago
  • 0.0.0-pr.70.1.5a0d2d1                                ...           a month ago
  • 0.9.0-next.8                                ...           a month ago
  • 0.0.0-pr.68.14.6e55a86                                ...           a month ago
  • 0.0.0-pr.68.13.1664c63                                ...           a month ago
  • 0.0.0-pr.68.12.a36f748                                ...           a month ago
  • 0.0.0-pr.68.11.be18674                                ...           a month ago
  • 0.0.0-pr.68.10.761be1a                                ...           a month ago
  • 0.0.0-pr.68.9.3d42aed                                ...           a month ago
  • 0.0.0-pr.68.8.f0dc029                                ...           a month ago
  • 0.0.0-pr.68.7.810ff3e                                ...           a month ago
  • 0.0.0-pr.68.6.1c6d484                                ...           a month ago
  • 0.0.0-pr.68.5.f432608                                ...           a month ago
  • 0.0.0-pr.68.4.f432608                                ...           a month ago
  • 0.0.0-pr.68.3.f432608                                ...           a month ago
  • 0.0.0-pr.68.2.f432608                                ...           a month ago
  • 0.0.0-pr.68.1.f432608                                ...           a month ago
  • 0.0.0-pr.66.5.1866785                                ...           a month ago
  • 0.0.0-pr.69.1.a82de72                                ...           a month ago
  • 0.0.0-pr.66.4.46e00e9                                ...           a month ago
  • 0.0.0-pr.66.3.f01d8be                                ...           a month ago
  • 0.0.0-pr.66.2.4fffc9f                                ...           a month ago
  • 0.0.0-pr.67.1.29c0576                                ...           a month ago
  • 0.0.0-pr.66.1.fcebf50                                ...           a month ago
  • 0.8.1-next.3                                ...           a month ago
  • 0.0.0-pr.62.4.7a1da7b                                ...           2 months ago
  • 0.0.0-pr.62.3.cc52ac7                                ...           2 months ago
  • 0.0.0-pr.64.1.d17b6a8                                ...           2 months ago
  • 0.0.0-pr.62.2.4185666                                ...           2 months ago
  • 0.0.0-pr.63.1.1551ddd                                ...           2 months ago
  • 0.0.0-pr.62.1.721cc76                                ...           2 months ago
  • 0.8.1-next.2                                ...           2 months ago
  • 0.0.0-pr.61.2.9c2f427                                ...           2 months ago
  • 0.0.0-pr.61.1.2a87439                                ...           2 months ago
  • 0.0.0-pr.60.1.67c6bbe                                ...           2 months ago
  • 0.0.0-pr.59.20.fdd781e                                ...           2 months ago
  • 0.0.0-pr.59.19.9693a9b                                ...           2 months ago
  • 0.0.0-pr.59.18.a3cea10                                ...           2 months ago
  • 0.0.0-pr.59.17.52138ec                                ...           2 months ago
  • 0.0.0-pr.59.16.f60556b                                ...           2 months ago
  • 0.0.0-pr.59.15.c976da8                                ...           2 months ago
  • 0.0.0-pr.59.14.4b4d9d0                                ...           2 months ago
  • 0.0.0-pr.59.13.df95c25                                ...           2 months ago
  • 0.0.0-pr.59.12.b6aaf44                                ...           2 months ago
  • 0.0.0-pr.59.11.a2e1b45                                ...           2 months ago
  • 0.0.0-pr.59.10.df6fc0f                                ...           2 months ago
  • 0.0.0-pr.59.9.c954eb5                                ...           2 months ago
  • 0.0.0-pr.59.8.a9a4130                                ...           2 months ago
  • 0.0.0-pr.59.7.af0f636                                ...           2 months ago
  • 0.0.0-pr.59.6.2304f72                                ...           2 months ago
  • 0.0.0-pr.59.5.b75df3f                                ...           2 months ago
  • 0.0.0-pr.59.4.341d5e9                                ...           2 months ago
  • 0.0.0-pr.59.3.375619f                                ...           2 months ago
  • 0.0.0-pr.59.2.fa08b93                                ...           2 months ago
  • 0.0.0-pr.59.1.2193c13                                ...           2 months ago
  • 0.8.1-next.1                                ...           2 months ago
  • 0.0.0-pr.54.1.8450677                                ...           2 months ago
  • 0.8.0                                ...           3 months ago
  • 0.8.0-next.1                                ...           3 months ago
  • 0.0.0-pr.53.3.0a8f84f                                ...           3 months ago
  • 0.0.0-pr.53.2.4b5805e                                ...           3 months ago
  • 0.0.0-pr.53.1.4c2f4a2                                ...           3 months ago
  • 0.7.1                                ...           3 months ago
  • 0.7.1-next.2                                ...           3 months ago
  • 0.0.0-pr.50.3.b1d9bc4                                ...           3 months ago
  • 0.0.0-pr.50.2.aaa9ab3                                ...           3 months ago
  • 0.0.0-pr.50.1.64707f3                                ...           3 months ago
  • 0.7.1-next.1                                ...           3 months ago
  • 0.7.0                                ...           3 months ago
  • 0.7.0-next.13                                ...           3 months ago
  • 0.7.0-next.12                                ...           3 months ago
  • 0.7.0-next.11                                ...           3 months ago
  • 0.7.0-next.10                                ...           3 months ago
  • 0.7.0-next.9                                ...           3 months ago
  • 0.7.0-next.8                                ...           3 months ago
  • 0.0.0-pr.49.1.9fb5e42                                ...           3 months ago
  • 0.7.0-next.7                                ...           3 months ago
  • 0.0.0-pr.47.1.805964d                                ...           3 months ago
  • 0.7.0-next.6                                ...           3 months ago
  • 0.7.0-next.5                                ...           3 months ago
  • 0.0.0-pr.45.2.e5796fc                                ...           3 months ago
  • 0.0.0-pr.45.1.a1e6e71                                ...           3 months ago
  • 0.7.0-next.4                                ...           3 months ago
  • 0.7.0-next.3                                ...           3 months ago
  • 0.7.0-next.2                                ...           3 months ago
  • 0.7.0-next.1                                ...           3 months ago
  • 0.0.1-next.1                                ...           3 months ago
  • 0.1.0-next.1                                ...           3 months ago
  • 0.0.0-pr.43.2.53af09d                                ...           3 months ago
  • 0.0.0-pr.43.1.fb1e8e5                                ...           3 months ago
  • 0.0.0-pr.30.3.685ba37                                ...           3 months ago
  • 0.0.0-pr.30.2.507afdf                                ...           3 months ago
  • 0.0.0-pr.30.1.35a8fa4                                ...           3 months ago
  • 0.0.0-pr.30.3a9ec9f                                ...           3 months ago
  • 0.0.0-pr.30.6f29f57                                ...           3 months ago
  • 0.0.0-pr.30.1c2e772                                ...           3 months ago
  • 0.0.0-pr.30.ee27408                                ...           3 months ago
  • 0.0.0-pr.30.1079baa                                ...           3 months ago
  • 0.6.1                                ...           3 months ago
  • 0.6.1-next.2                                ...           3 months ago
  • 0.6.1-next.1                                ...           3 months ago
  • 0.6.0                                ...           4 months ago
  • 0.6.0-next.2                                ...           4 months ago
  • 0.6.0-next.1                                ...           4 months ago
  • 0.5.0                                ...           4 months ago
  • 0.4.0                                ...           4 months ago
  • 0.3.2                                ...           4 months ago
  • 0.3.1                                ...           4 months ago
  • 0.3.0                                ...           4 months ago
  • 0.2.9                                ...           4 months ago
  • 0.2.9-next.2                                ...           5 months ago
  • 0.2.8-next.1                                ...           5 months ago
  • 0.2.8                                ...           5 months ago
  • 0.2.0                                ...           5 months ago
  • 0.2.7                                ...           5 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 240
Last Day 0
Last Week 120
Last Month 735
Dependencies (18)
Dev Dependencies (17)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |