Skip to content

Commit 6e3a35c

Browse files
chore(cd): add CD pipeline for npm release (#75)
* squash branch 2 * remove trailing whitespace * rename ci job * revert port number changes
1 parent e5624a1 commit 6e3a35c

File tree

4 files changed

+79
-11
lines changed

4 files changed

+79
-11
lines changed

Diff for: .github/workflows/cd-dgraph-js-http.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: cd-dgraph-js-http
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
releasetag:
6+
description: "git tag to checkout and version to publish to npm"
7+
required: true
8+
type: string
9+
jobs:
10+
dgraph-js-http-tests:
11+
runs-on: ubuntu-20.04
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
node-version: [16.x, 18.x, 19.x, 20.x]
16+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
17+
steps:
18+
- name: Checkout dgraph-js-http repo
19+
uses: actions/checkout@v3
20+
with:
21+
path: dgraph-js-http
22+
repository: dgraph-io/dgraph-js-http
23+
ref: ${{ github.event.inputs.releasetag }}
24+
- name: Checkout dgraph repo
25+
uses: actions/checkout@v3
26+
with:
27+
path: dgraph
28+
repository: dgraph-io/dgraph
29+
ref: main
30+
- name: Get Go Version
31+
run: |
32+
#!/bin/bash
33+
cd dgraph
34+
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
35+
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
36+
- name: Set up Go
37+
uses: actions/setup-go@v3
38+
with:
39+
go-version: ${{ env.GOVERSION }}
40+
- name: Build dgraph binary
41+
run: cd dgraph && make docker-image # also builds dgraph binary
42+
- name: Move dgraph binary to gopath
43+
run: cd dgraph && mv dgraph/dgraph ~/go/bin/dgraph
44+
- name: Setup node.js ${{ matrix.node-version }}
45+
uses: actions/setup-node@v3
46+
with:
47+
node-version: ${{ matrix.node-version }}
48+
cache: 'npm'
49+
cache-dependency-path: dgraph-js-http/package-lock.json
50+
- name: Run dgraph-js-http tests
51+
working-directory: dgraph-js-http
52+
run: |
53+
npm ci --legacy-peer-deps
54+
bash scripts/run-tests.sh
55+
56+
dgraph-js-http-publish-npm:
57+
needs: [dgraph-js-http-tests]
58+
runs-on: ubuntu-20.04
59+
steps:
60+
- name: Checkout dgraph-js-http repo
61+
uses: actions/checkout@v3
62+
- name: Setup node.js
63+
uses: actions/setup-node@v3
64+
with:
65+
node-version: '20.x'
66+
registry-url: 'https://registry.npmjs.org'
67+
- name: Build dgraph-js-http package
68+
run: npm ci --legacy-peer-deps
69+
- run: npm publish
70+
env:
71+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
72+

Diff for: .github/workflows/ci-aqua-security-trivy-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: aquasecurity/trivy-action@master
2525
with:
2626
scan-type: 'fs'
27-
scan-ref: '.'
27+
scan-ref: '.'
2828
format: 'sarif'
2929
output: 'trivy-results.sarif'
3030
- name: Upload Trivy scan results to GitHub Security tab

Diff for: .github/workflows/ci-dgraph-js-http.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
branches:
1414
- master
1515
jobs:
16-
build:
16+
dgraph-js-http-tests:
1717
runs-on: ubuntu-20.04
1818
strategy:
1919
fail-fast: false

Diff for: PUBLISHING.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ This document contains instructions to publish dgraph-js-http to [npm].
66

77
## Before deploying
88

9-
- Get access to credentials for Dgraph's account on npm with username dgraph-io
10-
- Run `npm login` to login to this account
9+
- Bump version by modifying the `version` field in `package.json` file
10+
- Run `npm install` to update the version in `package-lock.json` file
11+
- Commit these changes
1112

1213
## Deploying
1314

14-
- Build and test the code that needs to be published
15-
- Bump version by modifying the `version` field in `package.json` file
16-
- Run `npm install` to update the version in `package-lock.json` file
17-
- If necessary, update the `CHANGELOG.md` file to reflect new changes
18-
- Commit the changes
19-
- Run `npm publish` (for a next release run `npm publish --tag next`)
20-
- If necessary, create a new release tag on the Github repository
15+
- Publish github release notes (specify version tag upon publish)
16+
- Run `cd-dgraph-js-http` workflow (input: version tag)

0 commit comments

Comments
 (0)