-
Notifications
You must be signed in to change notification settings - Fork 3
38 lines (32 loc) · 1.17 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
---
on: push
jobs:
publish:
env:
# default dryrun publish to NPM
ENABLE_DRYRUN: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install
- run: npm test
# real publish after a PR to main branch
- if: ${{ startsWith(github.ref, 'refs/heads/main') }}
# see https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
run: |
# disable command workflow processing
echo "::stop-commands::`echo -n ${{ github.token }} | sha256sum | head -c 64`"
echo "::set-env name=ENABLE_DRYRUN::false"
# enable workflow command processing
echo "::`echo -n ${{ github.token }} | sha256sum | head -c 64`::"
- id: publish
uses: JS-DevTools/npm-publish@v1
with:
dry-run: ${{ env.ENABLE_DRYRUN }}
token: ${{ secrets.NPM_TOKEN }}
- if: steps.publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"