-
Notifications
You must be signed in to change notification settings - Fork 365
89 lines (77 loc) · 3.25 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: npm-publish
on:
push:
branches:
- main
env:
NPM_TAG: latest
jobs:
publish:
name: Publish to NPM
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Detect a version change and tag the new version
uses: steve9164/action-detect-and-tag-new-version@v1
id: detect
with:
tag-template: "{VERSION}"
use-annotated-tag: "true"
tagger-name: Terria Bot via GitHub Actions
tagger-email: [email protected]
- name: Version update detected
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
run: 'echo "Version change from ${{steps.detect.outputs.previous-version}} to ${{steps.detect.outputs.current-version}} detected"'
- name: Set up Node.js for NPM
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
uses: actions/setup-node@v2
with:
registry-url: "https://registry.npmjs.org"
node-version: "14.x"
- name: Install yarn
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
run: npm install -g yarn@^1.19.0
- name: Install dependencies
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
run: yarn install --ignore-engines
env:
NODE_OPTIONS: "--max_old_space_size=8192"
- name: Lint and build terriajs
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
run: npx gulp lint release
env:
NODE_OPTIONS: "--max_old_space_size=8192"
- name: Publish package to NPM
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
run: npm publish --tag ${NPM_TAG}
env:
NODE_OPTIONS: "--max_old_space_size=8192"
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# These slack success and failure message actions can be combined but it means there'll be no notification on a failed
# action-detect-and-tag-new-version. It also allows for a bit better message customisation
- name: Send success notification on Slack
if: steps.detect.outputs.previous-version != steps.detect.outputs.current-version
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,commit,action,ref
author_name: ${{ github.workflow }}
mention: here
if_mention: always
text: ":white_check_mark: Published v${{ steps.detect.outputs.current-version }} to https://www.npmjs.com/package/terriajs"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
- name: Send failure or cancellation notification on Slack
if: failure() || cancelled() # Pick up events even if the job fails or is canceled.
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,commit,action,ref
author_name: ${{ github.workflow }}
mention: here
if_mention: always
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required