-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (60 loc) · 2.49 KB
/
Copy pathnode.yml
File metadata and controls
70 lines (60 loc) · 2.49 KB
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ releases/ropsten/1.0.2-rc ]
pull_request:
branches: [ releases/ropsten/1.0.2-rc ]
repository_dispatch:
types: redeploy
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.11.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run build --if-present
- run: npm test
env:
CI: true
- if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
name: Bump and publish npm package
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -x
name=$(jq --raw-output .name package.json)
version=$(jq --raw-output .version package.json)
preid=$(echo $version | sed -e s/^.*-\\\([^.]*\\\).*$/\\1/)
# Find the latest published package version matching this preid.
# Note that in jq, we wrap the result in an array and then flatten;
# this is because npm show json contains a single string if there
# is only one matching version, or an array if there are multiple,
# and we want to look at an array always.
latest_version=$(npm show -json "$name@^$version" version | jq --raw-output "[.] | flatten | .[-1]")
latest_version=${latest_version:-$version}
if [ -z $latest_version ]; then
echo "Latest version calculation failed. Resolved info:"
echo "$name@$version ; preid $preid"
exit 1
fi
# Update package.json with the latest published package version matching this
# preid to prepare for bumping.
echo $(jq -M ".version=\"${latest_version}\"" package.json) > package.json
# Bump without doing any git work. Versioning is a build-time action for us.
# Consider including commit id? Would be +<commit id>.
npm version prerelease --preid=$preid --no-git-tag-version
# Fix resolved dependency versions.
npm update
# Publish to npm.
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
npm publish --access=public