-
-
Notifications
You must be signed in to change notification settings - Fork 8
76 lines (74 loc) · 2.77 KB
/
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Publish package
on:
pull_request:
branches:
- master
types: [closed]
jobs:
publish:
runs-on: ubuntu-20.04
if: github.event.pull_request.merged == true
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
fetch-depth: -1
- name: Use Node.js "14.x"
uses: actions/setup-node@v3
with:
cache: npm
node-version: "14.x"
- name: Install dependencies
run: npm install
env:
CI: true
- name: Check availability
id: check_availability
run: npx can-npm-publish
continue-on-error: true
- name: Check tag
id: check_tag
run: |
TAG=v$(jq -r ".version" package.json)
if git show-ref --tags | grep -q "refs/tags/${TAG}"
then
echo "${TAG} exists."
exit 1
else
echo "${TAG} does not exist. It will add to this repository."
fi
continue-on-error: true
- name: Publish
id: npm_publish
if: steps.check_availability.outcome == 'success' && steps.check_tag.outcome == 'success'
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Tagging
if: steps.npm_publish.conclusion == 'success'
run: |
TAG=v$(jq -r ".version" package.json)
git tag ${TAG}
git push origin --tags
- name: Post comment
uses: mshick/add-pr-comment@v2
if: steps.check_availability.outcome == 'success' && steps.check_tag.outcome == 'success'
with:
message: |
Thank you for your contributions!
We publish new version of this package.
Cheers!
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: "github-actions[bot]"
allow-repeats: false
- name: Post comment
uses: mshick/add-pr-comment@v2
if: steps.check_availability.outcome == 'failure' || steps.check_tag.outcome == 'failure'
with:
message: |
Thank you for your contributions!
We include your contributions in next release.
Cheers!
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: "github-actions[bot]"
allow-repeats: false