Skip to content

Commit

Permalink
Updated git push method.
Browse files Browse the repository at this point in the history
Updated readme.
  • Loading branch information
muratgozel committed Jul 3, 2022
1 parent bbae071 commit 457a1f8
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 53 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/markdown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/node-releaser.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 49 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# node-releaser
Automated versioning and package publishing tool. Supports semver and calver. Extendible with plugins.
Automated versioning and package publishing tool. Supports [semver](https://semver.org) and [calver](https://calver.org). Extendible with plugins.

![NPM](https://img.shields.io/npm/l/node-releaser)
[![npm version](https://badge.fury.io/js/node-releaser.svg)](https://badge.fury.io/js/node-releaser)
![npm bundle size](https://img.shields.io/bundlephobia/min/node-releaser)
![npm](https://img.shields.io/npm/dy/node-releaser)

It is simply: `releaser patch -m "commit message"` and you get this: ![](github-sample.png "Github Sample graphic")

## Introduction
`releaser` is based on `git` and `node.js`. Any developer who works with `git` can use it to automate releasing and publishing process of any project. Here is a summary of what can be done with releaser:
1. Use [semver](https://github.com/npm/node-semver) or [calver](https://github.com/muratgozel/node-calver) in your project. New versions computed automatically as you release. This feature based on git tags.
Expand All @@ -28,7 +30,34 @@ releaser --version
```

### Create A Configuration File (.releaser.json)
First, this is the schema to write valid configuration files:
In your project folder, create a configuration file. A sample could be:
```json
{
"versioning": {
"scheme": "semver"
},
"npm": {
"enable": true,
"updatePkgJson": true,
"publish": true
},
"github": {
"enable": true,
"release": true
}
}
```
This configuration will:
1. Generate the next version according to **semver** scheme,
2. Prefix the version number with **v** (because its by default),
3. Updates package.json version field (because npm.updatePkgJson enabled),
4. Push the changes to the remote repository (because github.enabled),
5. Creates a release on Github (because github.release),
6. Publishes the package on npm.

In order to Github releasing work we need to specify [Github access token](https://github.com/settings/tokens). It can be specified as env var `RELEASER_GITHUB_TOKEN=...` or a cli arg `--github-token` while executing the command. Optionally a credential management service such as [Doppler](https://www.doppler.com) can be used.

Releaser has various config options. This is the schema to write valid configuration files:
```js
versioning: {
scheme: {
Expand Down Expand Up @@ -192,36 +221,27 @@ cmd: {
}
}
```
An example `.releaser.json` file could be:
```json
{
"versioning": {
"scheme": "semver"
},
"npm": {
"enable": true,
"updatePkgJson": true,
"publish": true
},
"github": {
"enable": true,
"release": true
}
}
```
This configuration will:
1. Generate the next version according to **semver** scheme,
2. Prefix the version number with **v** (because its by default),
3. Updates package.json's version field (because npm.updatePkgJson enabled),
3. Push the changes to the remote repository (because github.enabled),
4. Creates a release on Github (because github.release),
5. Publishes the package on npm.
We didn't specify `github.token` because we can not put it inside file of course. We will specify it as env var `RELEASER_GITHUB_TOKEN=...` or a cli arg `--github-token`.

### Running releaser
Releaser only need two things in order to run. The level and commit messages. Level is the version level. major, minor etc. in semver or calendar, calendar.major etc. in calver. Commit messages are one or more -m flags that explain the changes in the codebase in that release.
Releaser only need two things in order to run. The level and commit messages. Level is the version level. major, minor etc. for **semver** or calendar, calendar.major etc. for **calver**. Commit messages are one or more -m flags that explain the changes in the codebase in that release.

Make a release:
```sh
releaser major -m "initial release."
```

Look at available commands:
Specify multiple messages:
```sh
releaser minor -m "fixed something" -m "added something."
```

Specify a tag as the current tag:
```sh
releaser major -m "initial release." --current-tag v3.0.0
```
Normally, releaser query git to find the current tag.

Available commands for reference:
```sh
releaser <cmd> [args]

Expand Down Expand Up @@ -271,22 +291,6 @@ Options:
--help Show help [boolean]
```

Make a release:
```sh
releaser major -m "initial release."
```

Specify multiple messages:
```sh
releaser minor -m "fixed something" -m "added something."
```

Specify a tag as the current tag:
```sh
releaser major -m "initial release." --current-tag v3.0.0
```
Normally, module query git to find the current tag.

## Default Plugins
1. **Github**: Github plugin is for creating releases on Github.
2. **Gitlab**: Gitlab plugin is for creating releases on Gitlab.
Expand Down
Binary file added github-sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-releaser",
"version": "0.7.0",
"version": "0.7.1",
"description": "Automated versioning and package publishing tool. Supports semver and calver. Extendible with plugins.",
"main": "src/index.js",
"bin": {
Expand Down
12 changes: 5 additions & 7 deletions src/modules/git/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,14 @@ function push(nextTag, messages) {
const branch = getBranchName()
const commands = [
'git tag -a "' + nextTag + '" ' + msgscmd,
'git add .',
'git add --ignore-removal .',
'git commit ' + msgscmd,
'git push --atomic origin ' + branch + ' ' + nextTag + ''
]
for (let i = 0; i < commands.length; i++) {
try {
execSync(commands[i], {stdio: 'inherit', encoding: 'utf8'})
} catch (e) {
throw e
}
try {
execSync(commands.join(' && '), {stdio: 'inherit', encoding: 'utf8'})
} catch (e) {
throw e
}
}

Expand Down

0 comments on commit 457a1f8

Please sign in to comment.