-
Notifications
You must be signed in to change notification settings - Fork 36
42 lines (39 loc) · 1.61 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: NPM publish CD workflow
on:
release:
# This specifies that the build will be triggered when we publish a release
types: [published]
jobs:
build:
# Run on latest version of ubuntu
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 }}
# install Node.js
- name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 18
# Specifies the registry, this field is required!
registry-url: 'https://registry.npmjs.org'
# clean install of your projects' deps. We use "npm ci" to avoid package lock changes
- run: yarn install
# set up git since we will later push to the repo
- run: git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" && git config --global user.name "$GITHUB_ACTOR"
# upgrade npm version in package.json to the tag used in the release.
- run: yarn version --new-version ${{ github.event.release.tag_name }}
# run tests just in case
- run: yarn test:2.0.0
# publish to NPM -> there is one caveat, continue reading for the fix
- run: npm publish
env:
NODE_AUTH_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 }}