-
Notifications
You must be signed in to change notification settings - Fork 52
74 lines (63 loc) · 2.29 KB
/
cd-javascript.yaml
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
name: CD-Javascript
on:
# When Pull Request is merged
pull_request_target:
types: [closed]
jobs:
Publish-NPM:
name: Publish javascript packages to npmjs.com
if: |
github.event.pull_request.user.login == 'polywrap-build-bot' &&
github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Read VERSION into env.RELEASE_VERSION
run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
- name: Read .nvmrc into env.NVMRC
run: echo NVMRC=$(cat .nvmrc) >> $GITHUB_ENV
- name: Is Pre-Release
run: |
STR="${RELEASE_VERSION}"
SUB='pre.'
if [[ "$STR" == *"$SUB"* ]]; then
echo PRE_RELEASE=true >> $GITHUB_ENV
else
echo PRE_RELEASE=false >> $GITHUB_ENV
fi
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '${{env.NVMRC}}'
- name: Auth into NPM
run: |
npm config set registry https://registry.npmjs.org/
npm config set //registry.npmjs.org/:_authToken=${{secrets.POLYWRAP_BUILD_BOT_NPM_PAT}}
echo $(npm whoami --registry https://registry.npmjs.org/)
- name: Install JS dependencies
run: yarn install --nonInteractive --frozen-lockfile
- name: Build JS packages
run: yarn build
- name: Publish Node Packages To NPM (Latest)
if: env.PRE_RELEASE == 'false'
run: yarn publish:npm
env:
NPM_AUTH_TOKEN: ${{secrets.POLYWRAP_BUILD_BOT_NPM_PAT}}
- name: Publish Node Packages To NPM (Pre-Release)
if: env.PRE_RELEASE == 'true'
run: yarn publish:pre:npm
env:
NPM_AUTH_TOKEN: ${{secrets.POLYWRAP_BUILD_BOT_NPM_PAT}}
- uses: actions/github-script@0.8.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '**[NPM Release Published](https://www.npmjs.com/search?q=polywrap) `${{env.RELEASE_VERSION}}`** 🎉'
})