Skip to content

Commit

Permalink
ci: update release process
Browse files Browse the repository at this point in the history
For more details on the release process, please read docs/RELEASE.md

In previous releases, we packaged the db2ia.node
and other extra files

Now we restrict the files packaged using the files section
of the package.json

https://docs.npmjs.com/cli/v8/configuring-npm/package-json#files
  • Loading branch information
abmusse committed Feb 1, 2024
1 parent 8f50478 commit 0628cc3
Show file tree
Hide file tree
Showing 9 changed files with 5,946 additions and 3,954 deletions.
46 changes: 46 additions & 0 deletions .github/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
pipeline {
agent {
node {
label 'ibmi7.3'
}
}
environment {
NODE_PATH = '/QOpenSys/pkgs/lib/nodejs18/bin'
}
stages {
stage('build') {
steps {
sh '''
export PATH=$NODE_PATH:$PATH
npm i
./node_modules/.bin/node-pre-gyp rebuild --production
./node_modules/.bin/node-pre-gyp package
'''
}
}
stage('create-gh-release') {
environment {
GH_TOKEN = credentials('idb-connector-gh-token')
}
steps {
sh '''
export PATH=$NODE_PATH:$PATH
export GITHUB_TOKEN=$GH_TOKEN_PSW
./node_modules/release-it/bin/release-it.js --ci --no-increment --no-git --github.release --github.update --no-plugins.@release-it/conventional-changelog.infile
'''
}
}
stage('create-npm-release') {
environment {
NPM_TOKEN = credentials('idb-connector-npm-token')
}
steps {
sh '''
export PATH=$NODE_PATH:$PATH
npm config set --location=project //registry.npmjs.org/:_authToken $NPM_TOKEN
./node_modules/release-it/bin/release-it.js --ci --no-increment --no-git --npm.publish --npm.skipChecks --no-plugins.@release-it/conventional-changelog.infile
'''
}
}
}
}
23 changes: 23 additions & 0 deletions .github/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e

PATH="/QOpenSys/pkgs/bin:$PATH"
DATE=$(date +"%Y-%m-%d_%H-%M-%S")
BRANCH="release-$DATE"
REMOTE="origin"
MAIN_BRANCH="master"

if [ ! -d node_modules ]; then
# install deps
npm install
fi

# checkout main branch and pull the latest changes
git checkout $MAIN_BRNACH
git pull $REMOTE $MAIN_BRANCH
# create release branch and run release
git checkout -b "$BRANCH" $REMOTE/$MAIN_BRANCH
npm run release
# push branch to upstream remote to open a PR
git push $REMOTE $BRANCH

18 changes: 0 additions & 18 deletions .github/workflows/publish.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build*
.lock*
lib/binding/
npm-debug.log
.npmrc
24 changes: 24 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"npm": {
"publish": false
},
"git": {
"commitMessage": "chore: release ${version}",
"push": false,
"tag": false
},
"github":{
"assets": ["build/stage/${version}/*.tar.gz"],
"release": false,
"autoGenerate": true,
"releaseName": "${version}"
},
"plugins": {
"@release-it/conventional-changelog": {
"header": "# idb-connector changelog",
"preset": "conventionalcommits",
"infile": "CHANGELOG.md",
"ignoreRecommendedBump": true
}
}
}
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Note that building isn't necessary for end-users and is more for developers look
cd nodejs-idb-connector
npm install --build-from-source
```
## Build Dependencies
### Build Dependencies
Note: sqlcli header files, GCC, and Python are required to compile the code.

```sh
Expand All @@ -119,20 +119,6 @@ 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
./node_modules/.bin/node-pre-gyp rebuild --production
./node_modules/.bin/node-pre-gyp package
```

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)
Expand Down
23 changes: 23 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Release

To create a new release the developer first needs to run `release.sh`
```sh
./release.sh
```

This script will create a new release branch, run release-it, push the new branch upstream.

From there the developer needs to:

1) Open a pull request, have it approved by at least 1 reviewer, and merged into the master branch
2) Create a new release and tag from the [GitHub Web UI](https://github.com/IBM/nodejs-idb-connector/releases/new) with the release and tag name matching the version number in package.json.


After the release is created our Jenkins instance will:

1) Build the package
2) Update the GH release with the binary asset
3) Publish the release to NPM

After the release, the package version should be bumped to a `*-devel` suffix.
This will make node-pre-gyp build from source in development builds or when installing the project from a git url.
Loading

0 comments on commit 0628cc3

Please sign in to comment.