Skip to content

Commit

Permalink
Add github action to publish on npm
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebeel authored Dec 6, 2020
1 parent e334c3f commit abd3e78
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is a basic workflow to help you get started with Actions

name: NPM publish

on:
release:
# This specifies that the build will be triggered when we publish a release
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# "ref" specifies the branch to check out.
# "github.event.release.target_commitish" is a global variable and specifies the branch the release targeted
ref: ${{ github.event.release.target_commitish }}
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
# set up git since we will later push to the repo
- run: git config --global user.name "GitHub CD bot"
- run: git config --global user.email "github-cd-bot@example.com"
- run: npm version ${{ github.event.release.tag_name }}
# build the project
- run: npm run build

- run: npm publish --access public --tag ${{ github.event.release.target_commitish }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: git push
env:
# The secret is passed automatically. Nothing to configure.
github-token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit abd3e78

Please sign in to comment.