Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the release script and readme #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,30 @@ Releasing the project requires these steps:
node scripts/release/release.js minor
```

2. The above release script should automatically update the package version and regenerate assets in ```dist``` & ```lib``` folders. Once assets are regenerated the script commits and tags the changes and will push them to remote and `npm publish` will be triggered automatically.
3. Once publish is complete make sure it's uploaded to [npm][project-url]
2. The above release script should automatically update the package version and regenerate assets in ```dist``` & ```lib``` folders. Once assets are regenerated the script commits the changes to a new branch and will push them to remote. Go to the branch repository on GitHub and create a PR from the newly created branch to the `master` branch. Once the PR is approved, merge it into the `master` branch.

## Publishing the Package

After the PR is created and merged into the `master` branch, follow these steps to publish the npm package:

1. **Pull the latest changes from the `master` branch**:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git checkout master
git pull origin master

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the ``` for code block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed bea8a3a

```
git checkout master
git pull origin master
```

2. **Create a tag and push the tag**:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git tag v{x.x.x}  # Replace {x.x.x} with the next release version
git push origin v{x.x.x}  # Replace {x.x.x} with the next release version

You can use ``` for code block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed bea8a3a

```
git tag v{x.x.x} # Replace {x.x.x} with the next release version
git push origin v{x.x.x} # Replace {x.x.x} with the next release version
```

3. **Publish the package to the npm registry**:
```
npm publish
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm publish

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed bea8a3a

```

4. Once publish is complete make sure it's uploaded to [npm][project-url]

Further explanation on the automated steps behind the ```release.js``` script can be found [here][release-documentation]

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"prepublishOnly": "npm whoami && npm test",
"preversion": "npm run test",
"version": "npm run build && git add -A",
"postversion": "git push && git push --tags && rm -rf build/temp",
"release:major": "node ./scripts/release/release.js major",
"release:minor": "node ./scripts/release/release.js minor",
"release:patch": "node ./scripts/release/release.js patch"
Expand Down
18 changes: 9 additions & 9 deletions scripts/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ Once the above ```node``` command gets executed the following takes place automa
1. Tests are triggered with the old version
2. Package version is updated based on the change type provided to the ```node``` command (e.g major, minor, patch, etc)
3. The library/package is rebuilt using new version to regenerate ```lib``` and ```dist``` folders (this includes running tests with new lib version)
4. All latest changes are commited and tagged.
5. Commits and updated tags are pushed to the origin.
6. The package publish mechanism is triggered
4. A new branch is created for the version bump.
5. All latest changes are commited and tagged.
6. A commit with the updated version is pushed to the new branch.
7. manually create a PR from the new branch to the master.

Steps 1-5 are accomplished using the following scripts in ```package.json``` :

Steps 1-6 are accomplished using the following scripts in ```package.json``` and release.js :
```
"preversion": "npm run test",
"version": "npm run build && git add -A",
"postversion": "git push && git push --tags && rm -rf build/temp",
```

## Testing the release process:
While modifying the scripts if in doubt you can always test the release process in a separate branch using the following steps without publishing the library:
1. Clone the project and create a new branch
2. Run ```npm install```
3. Modify the release script to temporarily remove : ```&& npm publish``` from line 8 of the release script.
4. Run ```node scripts/release/release.js minor```
5. It should perform the above listed release process steps and push the changes to your branch at origin.
6. Ensure the package version has been updated in ```package.json``` and ```package-lock.json```. The ```dist``` and ```lib``` folders should include files created with the updated version no.
3. Run ```node scripts/release/release.js minor```
4. It should perform the above listed release process steps and push the changes to your branch at origin.
5. Ensure the package version has been updated in ```package.json``` and ```package-lock.json```. The ```dist``` and ```lib``` folders should include files created with the updated version no.

19 changes: 17 additions & 2 deletions scripts/release/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ const shell = require('shelljs');

const releaseType = process.argv[2] || 'patch';

// npm version triggers scripts added in package.json to test, build, commit, tag and push changes with version update to git.
const newBranch = `release-${releaseType}-${new Date().toISOString().slice(0, 10)}`;

// Checkout a new branch
if (shell.exec(`git checkout -b ${newBranch}`).code !== 0) {
shell.echo('Error: Git branch creation failed');
shell.exit(1);
}

// Run npm version to bump the version and create a commit.npm version triggers scripts added in package.json to test, build, commit, tag and push changes with version update to git.
// If the tests fail when ran with preversion script entire release will fail.
if (shell.exec(`npm version ${releaseType} -m "Tagged and released version %s" && npm publish`).code !== 0) {
if (shell.exec(`npm version ${releaseType} -m "Tagged and released version %s"`).code !== 0) {
shell.echo('Error: Version bump failed');
shell.exit(1);
}

// Push the new branch to remote
if (shell.exec(`git push origin ${newBranch}`).code !== 0) {
shell.echo('Error: Git push failed');
shell.exit(1);
}

Expand Down