-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (46 loc) · 1.7 KB
/
npm-publish.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Publish to npmjs
on:
# When Release Pull Request is merged
pull_request:
branches:
- main
types: [closed]
permissions:
contents: write # for checkout and tag
pull-requests: write # for comments
packages: write # for publish
jobs:
publish-npm:
if: github.event.pull_request.merged == true && ${{ contains(github.event.head_commit.message, 'release main') }}
permissions:
contents: write
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # set this token manually
steps:
- name: "Checkout" # Download code from the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Checkout all branches and tags
ref: "${{ github.event.pull_request.base.ref }}"
token: ${{ secrets.BUILD_SVC_PAT }} # this is a PAT token generated with a personal user
# setup .npmrc using NODE_AUTH_TOKEN
- name: Setup .npmrc file for publish
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Configure Git User
run: |
git config --global user.email "${GITHUB_ACTOR}"
git config --global user.name "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Check if able to publish changes
run: npm whoami # will throw and exit if npm is not ready to publish
- name: "Install dependencies"
run: yarn install --immutable --immutable-cache --check-cache
- name: Build Packages for Release
run: yarn build
- name: "Publish to npmJS"
run: yarn run publish from-package --yes
env:
NODE_AUTH_TOKEN: "${{secrets.NPM_TOKEN}}"