From a557c831d27cfb42312405b4b3580da115e19820 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Fri, 28 Oct 2022 12:14:19 -0500 Subject: [PATCH] ci: Add npm publish action (#161) - Add publish action derived from https://github.com/actions/starter-workflows/blob/9bca5754a6e9b132c49c1715085c747b21278dc9/ci/npm-publish.yml#L4 Modified to skip `npm ci` and running integration tests because this would fail on non IBM i systems. - Document how to make a release - Simplify the build and release commands by using npm scripts --- .github/workflows/publish.yml | 18 ++++++++++++++++++ README.md | 16 +++++++++++++++- package.json | 5 ++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..09fda39 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +name: publish + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/README.md b/README.md index 422190f..d9ec86d 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Note that building isn't necessary for end-users and is more for developers look ```sh git clone git@github.com:IBM/nodejs-idb-connector.git cd nodejs-idb-connector - npm install --build-from-source + npm run build ``` ## Build Dependencies Note: sqlcli header files, GCC, and Python are required to compile the code. @@ -119,6 +119,20 @@ Note: sqlcli header files, GCC, and Python are required to compile the code. yum install python2 ``` +## Release + +```sh + git clone git@github.com:IBM/nodejs-idb-connector.git + cd nodejs-idb-connector + npm install + npm run build-release + +``` + +Create a new github release and attach the generated tar file in the `build` directory to the github release. + +After the release is created the [publish](.github/workflows/publish.yml) action will automatically publish to npm. + ## License [`MIT`](https://github.com/IBM/nodejs-idb-connector/blob/master/LICENSE) diff --git a/package.json b/package.json index e077005..7913290 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,10 @@ }, "scripts": { "test": "ln -sf ./build-tmp-napi-v3 ./build && ./node_modules/mocha/bin/mocha.js --timeout 5s", - "install": "node-pre-gyp install --fallback-to-build" + "test-node-versions": "nodever 12 && npm test test/dataTypes.js && nodever 14 && npm test test/dataTypes.js && nodever 16 && npm test test/dataTypes.js && nodever 18 && npm test test/dataTypes.js", + "install": "node-pre-gyp install --fallback-to-build", + "build": "npm install --build-from-source", + "build-release": "./node_modules/.bin/node-pre-gyp rebuild --production && ./node_modules/.bin/node-pre-gyp package" }, "dependencies": { "@mapbox/node-pre-gyp": "^1.0.10",