Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gh-publish

roman0x5815ISC2.2.5

Create a release for a node package on github.

changelog, github, release, semver, tag

readme

gh-publish

Create a release for a node package on GitHub.

npm travis standard downloads

Features

gh-publish example

Install

$ npm install gh-publish

Usage

Command-line interface

$ gh-publish
Your GitHub username: ungoldman
Your GitHub password: ✔✔✔✔✔✔✔✔

creating release v1.0.0 for ungoldman/cool-project

name:               v1.0.0
tag_name:           v1.0.0
target_commitish:   9561804a4d1fca2525d3207bec4907dd5ec7a705
body:

* engage

? publish release to github? Yes
https://github.com/ungoldman/cool-project/releases/tag/v1.0.0

Should be run at the root of the project to be released.

Expects a package.json and CHANGELOG.md in the working directory.

Prints release URL to stdout on success.

Uses ghauth for authentication with Github. A Github API OAuth token is saved to the gh-publish config directory after the first time authenticating. Note that the config directory is determined by application-config and is OS-specific.

Get usage info by running with --help or -h.

$ gh-publish --help
Usage: gh-publish [options]

Examples:
  gh-publish -n v2.0.3 -c master -d    create a draft release with title v2.0.3 tagged at HEAD of master


Options:
  -t, --tag_name          tag for this release
  -c, --target_commitish  commitish value for tag
  -n, --name              text of release title
  -b, --body              text of release body
  -o, --owner             repo owner
  -r, --repo              repo name
  -d, --draft             publish as draft                          [default: false]
  -p, --prerelease        publish as prerelease                     [default: false]
  --dry-run               dry run (stops before release step)       [default: false]
  -w, --workpath          path to working directory                 [default: "<current working directory>"]
  -e, --endpoint          GitHub API endpoint URL                   [default: "https://api.github.com"]
  -a, --assets            comma-delimited list of assets to upload  [default: false]
  -h, --help              Show help
  -v, --version           Show version number

Node API

var ghRelease = require('gh-publish')

// all options have defaults and can be omitted
var options = {
  tag_name: 'v1.0.0',
  target_commitish: 'master',
  name: 'v1.0.0',
  body: '* init\n',
  draft: false,
  prerelease: false,
  repo: 'gh-publish',
  owner: 'roman0x58',
  endpoint: 'https://api.github.com' // for GitHub enterprise, use http(s)://hostname/api/v3
}

// options can also be just an empty object
var options = {}

// auth is required
// it can either be a username & password...
options.auth = {
  username: 'roman0x58',
  password: 'XXXXXXXX'
}

// or an API token
options.auth = {
  token: 'XXXXXXXX'
}

ghRelease(options, function (err, result) {
  if (err) throw err
  console.log(result) // create release response: https://developer.github.com/v3/repos/releases/#response-4
})

Defaults

All default values taken from package.json unless specified otherwise.

name description default
tag_name release tag 'v' + version
target_commitish commitish value to tag HEAD of current branch
name release title 'v' + version
body release text CHANGELOG.md section matching version
owner repo owner repo owner in repository
repo repo name repo name in repository
draft publish as draft false
prerelease publish as prerelease false
assets release assets to upload false
endpoint GitHub API endpoint URL https://api.github.com

Override defaults with flags (CLI) or the options object (node).

Standards

Example

All releases of gh-publish were created with gh-publish.

Config location

Platform Location
OS X ~/Library/Application Support/gh-publish/config.json
Linux (XDG) $XDG_CONFIG_HOME/gh-publish/config.json
Linux (Legacy) ~/.config/gh-publish/config.json
Windows (> Vista) %LOCALAPPDATA%/gh-publish/config.json
Windows (XP, 2000) %USERPROFILE%/Local Settings/Application Data/gh-publish/config.json

Motivation

There are packages that already do something like this, and they're great, but I want something that does this one thing really well and nothing else, leans heavily on standards in package.json and CHANGELOG.md, and can work both as a CLI tool and programmatically in node.

Contributing

Contributions welcome! Please read the contributing guidelines first.

Tests

gh-publish uses standard]standard-url and [tape for testing. You can run all tests with npm test.

License

ISC

changelog

gh-release change log

All notable changes to this project will be documented in this file. Project versioning adheres to Semantic Versioning. Change log format is based on Keep a Changelog.

2.2.5 - 2017-05-26

Fixed

  • Move endpoint url to getDefaults fn

2.2.4 - 2017-05-26

Fixed

  • Default options through Node doesn't set

2.2.3 - 2017-05-26

Changed

  • Rename the gh-release project due it's not supported anymor`

2.2.1 - 2017-02-01

Fixed

  • bug: support package.json files where repository is a string (#44) - thanks @zeke

2.2.0 - 2016-12-03

Added

  • feature: add support for Github Enterprise (use endpoint option) (#44) - thanks @henryhuang

Miscellaneous

  • site: add scripts for generating a gh-pages site

2.1.0 - 2016-07-01

Changed

  • Using ghauth@^3.2.0 (better 2FA support). Config directory is now determined by application-config and is OS-specific. You may want to delete your old config directory (~/.config/gh-release).

Fixed

  • Trap failed authentication (#41)

2.0.3 - 2016-03-22

Changed

  • improve cli body preview
    • no word-wrap
    • no window-size
    • show newlines

Fixed

  • fix project URLs (ngoldman -> ungoldman)

2.0.2 - 2015-10-12

  • Use the most recently released version when comparing versions (#39)
  • Set travis-ci to test builds on 0.10, 0.12, and stable (#40)

2.0.1 - 2015-08-11

  • if target commit returns a 404, throw error

2.0.0 - 2015-04-28

Changed

  • breaking: changed API parameters from options, auth, callback to options, callback
    • auth is now in options as options.auth
  • moved all logging and CLI-related logic out of API and into CLI
  • no longer uses the node-github client

Added

  • assets option for uploading assets

1.1.8 - 2015-04-22

Fixed

  • exit process with code 1 on aborted release or invalid directory (#31)

1.1.7 - 2015-04-07

Fixed

  • If cli is successful, should exit with code of 0

1.1.6 - 2015-04-03

  • update demo
  • update doc

1.1.5 - 2015-04-02

  • more improvements to CLI style & formatting
  • bump changelog-parser to 2.x
  • bump standard to 3.x
  • readme updates

1.1.4 - 2015-04-01

  • improve preview style & formatting (#15 & #24)

1.1.3 - 2015-03-22

  • Handle error when release number already exists on github

1.1.2 - 2015-03-09

  • add dry-run and workpath options
  • add a get-defaults.js test
  • check if commit exists on github before trying to create release #11
  • add support for git URLs #16

1.1.1 - 2015-03-02

  • use changelog-parser for more reliable change log parsing

1.1.0 - 2015-03-01

  • target node 0.12 and iojs on travis
  • use docker and cache node_modules on travis
  • add oauth2 token authentication method #5
  • add CONTRIBUTING.md
  • refactor getDefaults, cli
  • fix error when in directories w/o package.json & CHANGELOG.md #9

1.0.8 - 2015-02-22

  • fix for standard #4
  • fix ordering in readme

1.0.7 - 2015-02-11

  • add standard to dev dependencies
  • add .travis.yml & badge for travis-ci
  • improve cli usage info & move to top of readme
  • add files to package.json for future build/zip/dist support

1.0.6 - 2015-02-08

  • move get-defaults.js to lib
  • improve usage info for cli
  • improve defaults management in cli
  • add proper target_commitish default

1.0.5 - 2015-02-08

  • hotfix for help/usage in dir w/o package.json or CHANGELOG.md

1.0.4 - 2015-02-07

  • remove files from package.json to fix cli again

1.0.3 - 2015-02-07

  • actual fix for cli.. should work fine now
  • allow v prefix for change log version names

1.0.2 - 2015-02-07

  • hotfix for local requires in cli

1.0.1 - 2015-02-07

  • add better options info to readme

1.0.0 - 2015-02-07

  • create working prototype
  • define basic node interface
  • define basic cli interface