forked from apache/tinkerpop
-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (76 loc) · 2.67 KB
/
build.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Build
on:
pull_request:
push:
branches:
- master
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [16.x]
os: [ubuntu-latest]
steps:
- id: setup-node
name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Check out code repository source code
uses: actions/checkout@v3
- working-directory: ./gremlin-javascript/src/main/javascript/gremlin-javascript
run: |
npm install
npm run lint
npm run unit-test
# Publishing is done in a separate job to allow
# for all matrix builds to complete.
release:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Check out repo
uses: actions/checkout@v3
- name: Publish new version?
working-directory: ./gremlin-javascript/src/main/javascript/gremlin-javascript
run: |
# Do not fail on errror
set +e
PACKAGE_NAME=$( node -p "require('./package.json').name" )
PUBLISHED_VERSION=$( npm view ${PACKAGE_NAME} version 2>/dev/null )
CURRENT_VERSION=$( node -p "require('./package.json').version" )
echo "Package: ${PACKAGE_NAME}"
echo "Published version: ${PUBLISHED_VERSION}"
echo "Current version: ${CURRENT_VERSION}"
if [ "${PUBLISHED_VERSION}" == "${CURRENT_VERSION}" ]; then
echo "Current version has already been published."
echo "publish=false" >> ${GITHUB_ENV}
else
echo "Current version has not been published. Publishing..."
echo "publish=true" >> ${GITHUB_ENV}
fi
echo NPM_PUBLISH_PACKAGE_NAME=${PACKAGE_NAME} >> ${GITHUB_ENV}
- name: Publish
if: env.publish == 'true'
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
working-directory: ./gremlin-javascript/src/main/javascript/gremlin-javascript
run: |
if [ "${NPM_AUTH_TOKEN}" == "" ]; then
echo "NPM_AUTH_TOKEN environment variable not found"
exit 2
fi
if [ "${NPM_PUBLISH_PACKAGE_NAME}" == "" ]; then
echo "NPM_PUBLISH_PACKAGE_NAME environment variable not found"
exit 3
fi
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
echo "Will publish ${NPM_PUBLISH_PACKAGE_NAME}"
npm publish --access public .