Home

Awesome

Release Please Action

Conventional Commits

Automate releases with Conventional Commit Messages.

Basic Configuration

  1. Create a .github/workflows/release-please.yml file with these contents:

    on:
      push:
        branches:
          - main
    
    permissions:
      contents: write
      pull-requests: write
    
    name: release-please
    
    jobs:
      release-please:
        runs-on: ubuntu-latest
        steps:
          - uses: googleapis/release-please-action@v4
            with:
              # this assumes that you have created a personal access token
              # (PAT) and configured it as a GitHub action secret named
              # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
              token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
              # this is a built-in strategy in release-please, see "Action Inputs"
              # for more options
              release-type: simple
    

    Specifying a release-type configuration is the most straight-forward configuration option, but allows for no further customization. For advanced configuration options, see the Advanced Configuration section

  2. Merge the above action into your repository and make sure new commits follow the Conventional Commits convention, release-please will start creating Release PRs for you.

Advanced Release Configuration

For any advanced configuration, please set up a manifest config and then configure this action as follows:

#...(same as above)
steps:
  - uses: googleapis/release-please-action@v4
    with:
      # this assumes that you have created a personal access token
      # (PAT) and configured it as a GitHub action secret named
      # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
      token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
      # optional. customize path to release-please-config.json
      config-file: release-please-config.json
      # optional. customize path to .release-please-manifest.json
      manifest-file: .release-please-manifest.json

Action Inputs

inputdescription
tokenA GitHub secret token, the action defaults to using the special secrets.GITHUB_TOKEN
release-typeIf specified, defines the release strategy to use for the repository. Reference Release types supported
pathcreate a release from a path other than the repository's root
target-branchbranch to open pull release PR against (detected by default)
config-filePath to the release-please config in the repository. Defaults to release-please-config.json
manifest-filePath to the release-please versions manifest. Defaults to .release-please-manifest.json
repo-urlGitHub repository name in the form of <owner>/<repo>. Defaults to the repository the action is running in.
github-api-urlOverride the GitHub API URL.
github-graphql-urlOverride the GitHub GraphQL URL
forkIf true, send the PR from a fork. This requires the token to be a user that can create forks (e.g. not the default GITHUB_TOKEN)
include-component-in-tagIf true, add prefix to tags and branches, allowing multiple libraries to be released from the same repository
proxy-serverConfigure a proxy servier in the form of <host>:<port> e.g. proxy-host.com:8080
skip-github-releaseIf true, do not attempt to create releases. This is useful if splitting release tagging from PR creation.
skip-github-pull-requestIf true, do not attempt to create release pull requests. This is useful if splitting release tagging from PR creation.

GitHub Credentials

release-please requires a GitHub token to access the GitHub API. You configure this token via the token configuration option.

[!WARNING]
If using GitHub Actions, you will need to specify a token for your workflows to run on Release Please's releases and PRs.

By default, Release Please uses the built-in GITHUB_TOKEN secret. However, all resources created by release-please (release tag or release pull request) will not trigger future GitHub actions workflows, and workflows normally triggered by release.created events will also not run. From GitHub's docs:

When you use the repository's GITHUB_TOKEN to perform tasks, events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs.

You will want to configure a GitHub Actions secret with a Personal Access Token if you want GitHub Actions CI checks to run on Release Please PRs.

Workflow Permissions

This workflow will need the following permissions in your workflow file:

permissions:
  contents: write
  pull-requests: write

You may also need to set "Allow GitHub Actions to create and approve pull requests" under repository Settings > Actions > General.

For more information about permissions:

Release Types Supported

Release Please automates releases for the following flavors of repositories:

release typedescription
dartA repository with a pubspec.yaml and a CHANGELOG.md
elixirAn elixir repository with a mix.exs and a CHANGELOG.md
expoAn Expo based React Native repository, with a package.json, app.json and CHANGELOG.md
goGo repository, with a CHANGELOG.md
helmA helm chart repository with a Chart.yaml and a CHANGELOG.md
javaA strategy that generates SNAPSHOT version after each release
krm-blueprintA kpt package, with 1 or more KRM files and a CHANGELOG.md
mavenStrategy for Maven projects, generates SNAPSHOT version after each release and updates pom.xml automatically
nodeA Node.js repository, with a package.json and CHANGELOG.md
ocamlAn OCaml repository, containing 1 or more opam or esy files and a CHANGELOG.md
pythonA Python repository, with a setup.py, setup.cfg, version.py and CHANGELOG.md and optionally a pyproject.toml and a <project>/__init__.py
phpA php composer package with composer.json and CHANGELOG.md
rubyA Ruby repository, with version.rb and CHANGELOG.md
rustA Rust repository, with a Cargo.toml (either as a crate or workspace) and a CHANGELOG.md
sfdxA repository with a sfdx-project.json and a CHANGELOG.md
simpleA repository with a version.txt and a CHANGELOG.md
terraform-moduleA terraform module, with a version in the README.md, and a CHANGELOG.md

New types of releases can be added here.

You can also find them in the release-please repository.

Outputs

Properties that are available after the action executed.

outputdescription
releases_createdtrue if any release was created, false otherwise
paths_releasedA JSON string of the array of paths that had releases created ([] if )
prs_createdtrue if any pull request was created or updated
prA JSON string of the PullRequest object (unset if no release created)
prsA JSON string of the array of PullRequest objects (unset if no release created)

Root component outputs

If you have a root component (path is . or unset), then the action will also output:

outputdescription
release_createdtrue if a root component release was created, false otherwise
upload_urlDirectly related to Create a release API
html_urlDirectly related to Create a release API
tag_nameDirectly related to Create a release API
majorNumber representing major semver value
minorNumber representing minor semver value
patchNumber representing patch semver value
shaSHA that a GitHub release was tagged at

Path outputs

If you have a monorepo or a component with path different than the root (.) directory, then your outputs will have the path prefixed to the output name.

This prefix allows you to distinguish values for different releases.

outputdescription
<path>--release_createdtrue if the release was created, false otherwise
<path>--upload_urlDirectly related to Create a release API
<path>--html_urlDirectly related to Create a release API
<path>--tag_nameDirectly related to Create a release API
<path>--majorNumber representing major semver value
<path>--minorNumber representing minor semver value
<path>--patchNumber representing patch semver value
<path>--shasha that a GitHub release was tagged at

If the path contains / you can access the outputs by using javascript like property access steps.release.outputs[<path>--...] e.g.:

run: npm publish --workflow packages/my-module
if: ${{ steps.release.outputs['packages/my-module--release_created'] }}

How release please works

Release Please automates CHANGELOG generation, the creation of GitHub releases, and version bumps for your projects. Release Please does so by parsing your git history, looking for Conventional Commit messages, and creating release PRs.

What's a Release PR?

Rather than continuously releasing what's landed to your default branch, release-please maintains Release PRs:

<img width="400" src="/screen.png">

These Release PRs are kept up-to-date as additional work is merged. When you're ready to tag a release, simply merge the release PR.

How should I write my commits?

Release Please assumes you are using Conventional Commit messages.

The most important prefixes you should have in mind are:

Supporting multiple release branches

release-please has the ability to target not default branches. You can even use separate release strategies (release-type). To configure, simply configure multiple workflows that specify a different target-branch:

Configuration for main (default) branch (.github/workflows/release-main.yaml):

on:
  push:
    branches:
      - main
      - 1.x
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        with:
          release-type: node
          # The short ref name of the branch or tag that triggered
          #  the workflow run. For example, `main` or `1.x`
          target-branch: ${{ github.ref_name }}

Automating publication to npm

With a few additions, the Release Please action can be made to publish to npm when a Release PR is merged:

on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          release-type: node
      # The logic below handles the npm publication:
      - uses: actions/checkout@v4
        # these if statements ensure that a publication only occurs when
        # a new release is created:
        if: ${{ steps.release.outputs.release_created }}
      - uses: actions/setup-node@v4
        with:
          node-version: 12
          registry-url: 'https://registry.npmjs.org'
        if: ${{ steps.release.outputs.release_created }}
      - run: npm ci
        if: ${{ steps.release.outputs.release_created }}
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
        if: ${{ steps.release.outputs.release_created }}

So that you can keep 2FA enabled for npm publications, we recommend setting registry-url to your own Wombat Dressing Room deployment.

Creating major/minor tags

If you are using release-please to publish a GitHub action, you will likely want to tag a major and minor tag during a release, i.e., if you are releasing v2.8.3, you will also want to update tags v2 and v2.8. This allows your users to pin to v2, and get updates to your library without updating their workflows.

The release-please-action has the outputs major, minor, and release_created to facilitate this. These outputs can be used conditionally, like so:

on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          release-type: node
      - uses: actions/checkout@v4
      - name: tag major and minor versions
        if: ${{ steps.release.outputs.release_created }}
        run: |
          git config user.name github-actions[bot]
          git config user.email 41898282+github-actions[bot]@users.noreply.github.com
          git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/googleapis/release-please-action.git"
          git tag -d v${{ steps.release.outputs.major }} || true
          git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
          git push origin :v${{ steps.release.outputs.major }} || true
          git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
          git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}"
          git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
          git push origin v${{ steps.release.outputs.major }}
          git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}

Attaching files to the GitHub release

You can attach additional files, such as release artifacts, to the GitHub release that is created. The gh CLI tool, which is installed on all runners, can be used for this.

This example uses the gh tool to attach the file ./artifact/some-build-artifact.zip:

on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          release-type: node
      - name: Upload Release Artifact
        if: ${{ steps.release.outputs.release_created }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh release upload ${{ steps.release.outputs.tag_name }} ./artifact/some-build-artifact.zip

Upgrading from v3 to v4

Command

If you were setting the command option, you will likely need to modify your configuration.

CommandNew ConfigurationDescription
github-releaseskip-github-pull-request: trueThis command was used for only tagging releases. Now we tell release-please to skip opening release PRs.
release-prskip-github-release: trueThis command was used for only opening release PRs. Now we tell release-please to skip tagging releases.
manifestdo not set release-type optionThis command told release-please to use a manifest config file. This is now the default behavior unless you explicitly set a release-type.
manifest-prskip-github-release: true and do not set release-type optionThis command told release-please to use a manifest config file and only open the pull reuqest.

Package options

If you were previously configuring advanced options via GitHub action inputs, you will need to configure via the release-please manifest configuration instead. Below, you can see a mapping of the old option to the new option:

Old OptionNew OptionNotes
path$.packagesThe root packages field is an object where the key is the path being configured
changelog-path$.packages[path].changelog-pathPackage-only option
component$.packages[path].componentPackage-only option
package-name$.packages[path].package-namePackage-only option
always-link-local$.always-link-localRoot-only option
bootstrap-sha$.bootstrap-shaRoot-only option
commit-search-depth$.commit-search-depthRoot-only option
group-pull-request-title-pattern$.group-pull-request-title-patternRoot-only option
last-release-sha$.last-release-shaRoot-only option
plugins$.pluginsRoot-only option
release-search-depth$.release-search-depthRoot-only option
sequential-calls$.sequential-callsRoot-only option
skip-labeling$.skip-labelingRoot-only option
signoff$.signoffRoot-only option
bump-minor-pre-major$.bump-minor-pre-major or $.packages[path].bump-minor-pre-majorRoot or per-package option
bump-patch-for-minor-pre-major$.bump-path-for-minor-pre-major or $.packages[path].bump-path-for-minor-pre-majorRoot or per-package option
changelog-host$.changelog-host or $.packages[path].changelog-hostRoot or per-package option
changelog-notes-type$.changelog-type or $.packages[path].changelog-typeRoot or per-package option
changelog-types$.changelog-sections or $.packages[path].changelog-sectionsRoot or per-package option
extra-files$.extra-files or $.packages[path].extra-filesRoot or per-package option
include-v-in-tag$.include-v-in-tag or $.packages[path].include-v-in-tagRoot or per-package option
labels$.label or $.packages[path].labelRoot or per-package option
monorepo-tags$.include-component-in-tag or $.packages[path].include-component-in-tagRoot or per-package option
prerelease$.prerelease or $.packages[path].prereleaseRoot or per-package option
pull-request-header$.pull-request-header or $.packages[path].pull-request-headerRoot or per-package option
pull-request-title-pattern$.pull-request-title-pattern or $.packages[path].pull-request-title-patternRoot or per-package option
release-as$.release-as or $.packages[path].release-asRoot or per-package option
release-labels$.release-label or $.packages[path].release-labelRoot or per-package option
release-type$.release-type or $.packages[path].release-typeRoot or per-package option
separate-pull-requests$.separate-pull-requests or $.packages[path].separate-pull-requestsRoot or per-package option
skip-github-release$.skip-github-release or $.packages[path].skip-github-releaseRoot or per-package option
snapshot-labels$.snapshot-label or $.packages[path].snapshot-labelRoot or per-package option
tag-separator$.tag-separator or $.packages[path].tag-separatorRoot or per-package option
version-file$.version-file or $.packages[path].version-fileRoot or per-package option
versioning-strategy$.versioning or $.packages[path].versioningRoot or per-package option

License

Apache Version 2.0