From 3815b6b90a141edeabbba1afc8526353bcb89e4f Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Wed, 20 May 2020 22:01:53 -0700 Subject: [PATCH] docs: document automating publication (#27) --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index 9a1d8ab..c0a57d3 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,48 @@ The most important prefixes you should have in mind are: * `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. +## Automating publication to npm + +With a few additions, the Release Please action can be made to publish to +npm when a Release PR is merged: + +```yaml +on: + push: + branches: + - master +name: release-please +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: bcoe/release-please-action@v1.2.1 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: node + package-name: test-release-please + # The logic below handles the npm publication: + - uses: actions/checkout@v2 + # these if statements ensure that a publication only occurs when + # a new release is created: + if: ${{ steps.release.outputs.release_created }} + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} + - run: npm ci + if: ${{ steps.release.outputs.release_created }} + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.release_created }} +``` + +> So that you can keep 2FA enabled for npm publications, we recommend setting +`registry-url` to your own [Wombat Dressing Room](https://github.com/GoogleCloudPlatform/wombat-dressing-room) deployment. + ## License Apache Version 2.0