Skip to content

Commit

Permalink
Create CD workflow for publishing to NPM registry
Browse files Browse the repository at this point in the history
  • Loading branch information
tsamantanis committed Apr 12, 2021
1 parent 3a057d9 commit bd6239b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// .github/workflows.yml
name: NPM publish CD workflow

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
# install Node.js
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn install
# set up git since we will later push to the repo
- run: git config --global user.name "tsamantanis"
- run: git config --global user.email "philip.tsamantanis@icloud.com"
# upgrade npm version in package.json to the tag used in the release.
- run: npm version ${{ github.event.release.tag_name }}
# build the project
- run: npm run build
# run tests just in case
- run: npm test
- run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"
# publish to NPM -> there is one caveat, continue reading for the fix
- run: npm publish --tag ${{ github.event.release.target_commitish }}
# deploy example to GH pages
- run: npm deploy
env:
# Use a token to publish to NPM. See below for how to set it up
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# push the version changes to GitHub
- run: git push
env:
# The secret is passed automatically. Nothing to configure.
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bd6239b

Please sign in to comment.