Skip to content

Commit

Permalink
chore(cd): add CD pipeline for npm release (#75)
Browse files Browse the repository at this point in the history
* squash branch 2
* remove trailing whitespace
* rename ci job
* revert port number changes
  • Loading branch information
joshua-goldstein authored Jul 5, 2023
1 parent e5624a1 commit 6e3a35c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 11 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/cd-dgraph-js-http.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: cd-dgraph-js-http
on:
workflow_dispatch:
inputs:
releasetag:
description: "git tag to checkout and version to publish to npm"
required: true
type: string
jobs:
dgraph-js-http-tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
node-version: [16.x, 18.x, 19.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout dgraph-js-http repo
uses: actions/checkout@v3
with:
path: dgraph-js-http
repository: dgraph-io/dgraph-js-http
ref: ${{ github.event.inputs.releasetag }}
- name: Checkout dgraph repo
uses: actions/checkout@v3
with:
path: dgraph
repository: dgraph-io/dgraph
ref: main
- name: Get Go Version
run: |
#!/bin/bash
cd dgraph
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVERSION }}
- name: Build dgraph binary
run: cd dgraph && make docker-image # also builds dgraph binary
- name: Move dgraph binary to gopath
run: cd dgraph && mv dgraph/dgraph ~/go/bin/dgraph
- name: Setup node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: dgraph-js-http/package-lock.json
- name: Run dgraph-js-http tests
working-directory: dgraph-js-http
run: |
npm ci --legacy-peer-deps
bash scripts/run-tests.sh
dgraph-js-http-publish-npm:
needs: [dgraph-js-http-tests]
runs-on: ubuntu-20.04
steps:
- name: Checkout dgraph-js-http repo
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Build dgraph-js-http package
run: npm ci --legacy-peer-deps
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/ci-aqua-security-trivy-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-dgraph-js-http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
branches:
- master
jobs:
build:
dgraph-js-http-tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand Down
14 changes: 5 additions & 9 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ This document contains instructions to publish dgraph-js-http to [npm].

## Before deploying

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

## Deploying

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

0 comments on commit 6e3a35c

Please sign in to comment.