Skip to content

transferwise/release-to-github-with-changelog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

release-to-github-with-changelog

npm version

Node v6.9.1 is required

Goal

Keep the released npm package in sync with the GitHub repo master branch:

  • the last CHANGELOG.md item is in sync with the last release on Github, with corresponding version tag
  • the package.json version is in sync with the master branch version tag

alt tag

Usage

The sources of truth are CHANGELOG.md and package.json. Your interface is your CHANGELOG.md.

CHANGELOG.md

Every CHANGELOG.md item should represent a release note of the version it describes:

# v0.2.0 //version tag
## The release title
// The release description in markdown

# v0.1.9
...

Full example:

# v0.2.0
## We can fly
Great news! The machine can now also fly!

# v0.1.0
## We can move
### What the machine does
It can move, a bit slowly but still it moves.

//...

Export a GITHUB_TOKEN env variable

Either locally with export GITHUB_TOKEN=$yourToken or in your CI tool settings (see CircleCI example).

Example of package.json

Don't forget the repository.url. It will be parsed to extract the repository full name (myOrg/myRepo in this example).

Test tool

You can include a check of your CHANGELOG.md format in your test command by using the provided release-to-github-with-changelog-pre-release-checks command.

{
  "version": "0.2.0",
  "respository": {
    "type": "git",
    "url": "git+https://github.com/myOrg/myRepo.git"
  },
  "files": ["dist"],
  "scripts": {
    "build": // build dist files
    "release": "npm publish && npm run release-to-github-with-changelog",
    "release": "npm publish && npm run release-to-github-with-changelog --branch=releases", // optional branch name
    "test": "release-to-github-with-changelog-pre-release-checks && karma start"
  }
}

CI example

circle.yml

machine:
  node:
    version: 4.1.0
dependencies:
  pre:
    - echo -e "$NPM_USER\n$NPM_PASS\n$NPM_EMAIL" | npm login
deployment:
  production:
    branch: master
    commands:
      - npm run release