New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

release-drafter-github-app

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

release-drafter-github-app

A GitHub app that bumps version numbers in readmes

  • 5.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
84
increased by1.2%
Maintainers
1
Weekly downloads
 
Created
Source

Release Drafter Logo

Drafts your next release notes as pull requests are merged into master. Built with Probot.


NPM package

Usage

You can use Release Drafter as a GitHub Action, by configuring your .github/main.workflow file with the following:

workflow "Push" {
  on = "push"
  resolves = ["Draft Release"]
}

action "Draft Release" {
  uses = "toolmantim/release-drafter@v5.1.1"
  secrets = ["GITHUB_TOKEN"]
}

You can also install the Release Drafter GitHub App, choosing the repositories you want releases automatically created.

Once you’ve added Release Drafter to your repository, it can be enabled by adding a .github/release-drafter.yml configuration file to each repository.

Example

For example, take the following .github/release-drafter.yml file in a repository:

template: |
  ## What’s Changed

  $CHANGES

As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready:

Screenshot of generated draft release

The following is a more complicated configuration, which categorises the changes into headings, and automatically suggests the next version number:

name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
  - title: '🚀 Features'
    labels:
      - 'feature'
      - 'enhancement'
  - title: '🐛 Bug Fixes'
    labels:
      - 'fix'
      - 'bugfix'
      - 'bug'
  - title: '🧰 Maintenance'
    label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
  ## Changes

  $CHANGES

Configuration Options

You can configure Release Drafter using the following key in your .github/release-drafter.yml file:

KeyRequiredDescription
templateRequiredThe template for the body of the draft release. Use template variables to insert values.
name-templateOptionalThe template for the name of the draft release. For example: "v$NEXT_PATCH_VERSION".
tag-templateOptionalThe template for the tag of the draft release. For example: "v$NEXT_PATCH_VERSION".
version-templateOptionalThe template to use when calculating the next version number for the release. Useful for projects that don't use semantic versioning. Default: "$MAJOR.$MINOR.$PATCH"
change-templateOptionalThe template to use for each merged pull request. Use change template variables to insert values. Default: "* $TITLE (#$NUMBER) @$AUTHOR".
no-changes-templateOptionalThe template to use for when there’s no changes. Default: "* No changes".
branchesOptionalThe branches to listen for configuration updates to .github/release-drafter.yml and for merge commits. Useful if you want to test the app on a pull request branch. Default is the repository’s default branch.
categoriesOptionalCategorize pull requests using labels. Refer to Categorize Pull Requests to learn more about this option.
exclude-lablesOptionalExclude pull requests using labels. Refer to Exclude Pull Requests to learn more about this option.
replacersOptionalSearch and replace content in the generated changelog body. Refer to Replacers to learn more about this option.
sort-directionOptionalSort changelog by merged date in ascending or descending order. Can be one of: ascending, descending. Default: descending.

Release Drafter also supports Probot Config, if you want to store your configuration files in a central repository. This allows you to share configurations between projects, and create a organization-wide configuration file by creating a repository named .github with the file .github/release-drafter.yml.

Template Variables

You can use any of the following variables in your template:

VariableDescription
$CHANGESThe markdown list of pull requests that have been merged.
$CONTRIBUTORSA comma separated list of contributors to this release (pull request authors, commit authors, and commit committers).
$PREVIOUS_TAGThe previous releases’s tag.

Next Version Variables

You can use any of the following variables in your template, name-template and tag-template:

VariableDescription
$NEXT_PATCH_VERSIONThe next patch version number. For example, if the last tag or release was v1.2.3, the value would be v1.2.4. This is the most commonly used value.
$NEXT_MINOR_VERSIONThe next minor version number. For example, if the last tag or release was v1.2.3, the value would be v1.3.0.
$NEXT_MAJOR_VERSIONThe next major version number. For example, if the last tag or release was v1.2.3, the value would be v2.0.0.

Version Template Variables

You can use any of the following variables in version-template to format the $NEXT_{PATCH,MINOR,MAJOR}_VERSION variables:

VariableDescription
$PATCHThe patch version number.
$MINORThe minor version number.
$MAJORThe major version number.

Change Template Variables

You can use any of the following variables in change-template:

VariableDescription
$NUMBERThe number of the pull request, e.g. 42.
$TITLEThe title of the pull request, e.g. Add alien technology.
$AUTHORThe pull request author’s username, e.g. gracehopper.

Categorize Pull Requests

With the categories option you can categorize pull requests in release notes using labels. For example, append the following to your .github/release-drafter.yml file:

categories:
  - title: '🚀 Features'
    label: 'feature'
  - title: '🐛 Bug Fixes'
    labels:
      - 'fix'
      - 'bugfix'
      - 'bug'

Pull requests with the label "feature" or "fix" will now be grouped together:

Screenshot of generated draft release with categories

Adding such labels to your PRs can be automated by using PR Labeler or Probot Auto Labeler.

Exclude Pull Requests

With the exclude-labels option you can exclude pull requests from the release notes using labels. For example, append the following to your .github/release-drafter.yml file:

exclude-labels:
  - 'skip-changelog'

Pull requests with the label "skip-changelog" will now be excluded from the release draft.

Replacers

You can search and replace content in the generated changelog body, using regular expressions, with the replacers option. Each replacer is applied in order.

replacers:
  - search: '/CVE-(\d{4})-(\d+)/g'
    replace: 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-$1-$2'
  - search: 'myname'
    replace: 'My Name'

Projects that don't use Semantic Versioning

If your project doesn't follow Semantic Versioning you can still use Release Drafter, but you may want to set the version-template option to customize how the $NEXT_{PATCH,MINOR,MAJOR}_VERSION environment variables are generated.

For example, if your project doesn't use patch version numbers, you can set version-template to $MAJOR.$MINOR. If the current release is version 1.0, then $NEXT_MINOR_VERSION will be 1.1.

GitHub Installation Permissions

Release Drafter requires full write, because GitHub does not offer a limited scope for only writing releases. Don't install Release Drafter to your entire GitHub account — only add the repositories you want to draft releases on.

Developing

If you have Node v10+ installed locally, you can run the tests, and a local app, using the following commands:

# Install dependencies
yarn

# Run the tests
npm test

# Run the app locally
npm run dev

Once you've started the app, visit localhost:3000 and you'll get step-by-step instructions for installing it in your GitHub account so you can start pushing commits and testing it locally.

If you don’t have Node installed, you can use Docker Compose:

# Run the tests
docker-compose run --rm app npm test

Contributing

Third-party contributions are welcome! 🙏🏼 See CONTRIBUTING.md for step-by-step instructions.

If you need help or have a question, let me know via a GitHub issue.

Deployment

If you want to deploy your own copy of Release Drafter, follow the Probot Deployment Guide.

Releasing

Run the following command:

git checkout master && git pull && npm version [major | minor | patch]

The command does the following:

  • Ensures you’re on master and don’t have local, un-commited changes
  • Bumps the version number in package.json based on major, minor or patch
  • Runs the postversion npm script in package.json, which:
    • Pushes the tag to GitHub
    • Publishes the npm release
    • Deploys to Now
    • Opens the GitHub releases page so you can publish the release notes

FAQs

Package last updated on 26 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc