/release-me-action

A GitHub Action for creating GitHub releases with Semantic Release.

Primary LanguageTypeScriptMIT LicenseMIT

license GitHub Actions Status GitHub Actions Status Coveralls code style: prettier Commitizen friendly

Release Me Action

This action uses Semantic Release to create a new release of the repository checked-out under $GITHUB_WORKSPACE, performing the following tasks:

  • analyzes commits based on the Angular Commit Message Conventions
  • updates the CHANGELOG.md file based on the analyzed commits
  • optionally, bumps the NPM package version number
  • optionally, commits workflow generated assets to the repository
  • optionally, adds workflow generated assets to the release
  • creates a GitHub release based on the analyzed commits

Usage

steps:
  - env:
      # Credentials used to perform the release and commit the updated assets
      # to the repository.
      # Required: true
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      # Configure Semantic Release branches parameter:
      # https://semantic-release.gitbook.io/semantic-release/usage/workflow-configuration#branches-properties
      #
      # If not specified, Semantic Release will use its default branches
      # configuration, specified in the API documentation:
      # https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches
      release-branches: '["+([0-9])?(.{+([0-9]),x}).x","master","next","next-major",{"name":"beta","prerelease":"beta"},{"name":"alpha","prerelease":"alpha"}]',
      # Commit the new line separated glob patterns to the repository as part
      # of the release process.
      commit-assets: |
        ./dist
      # Run semantic release in dry-run mode.
      # Default: false
      dry-run: true
      # Bump the node module version and commit the changed package files to the
      # repository as part of the release process.
      # Default: false
      node-module: true
      # Attach the new line separated listed glob patterns to the release.
      release-assets: |
        ./generated/my-asset.tar.gz
      # Configure the semantic release commit analyzer rules that are used to
      # determine the correct release version.
      # https://www.npmjs.com/package/@semantic-release/commit-analyzer#releaserules
      release-rules:
        '[{ "release": "patch", "type": "build" }, { "release": "patch", "type":
        "chore(deps)" }, { "release": "patch", "type": "chore(deps-dev)" }]'

IMPORTANT GITHUB_TOKEN does not have the required permissions to operate on protected branches. If you are using this action to release to a protected branch, replace the GITHUB_TOKEN with a GitHub Personal Access Token with the required permissions enabled on it.

Scenarios

Create a release

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master

Output release details

Output parameters supported:

  • version: Released version in format of X.Y.Z (major.minor.patch).
  • level: Released level (major, minor or patch).
  • released: Release status (boolean string).
steps:
  - name: Release
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    uses: ridedott/release-me-action@master
  - name: Output
        if: steps.build_package.outputs.released == 'true'
        run: |
          echo released version: ${{ steps.build_package.outputs.version }}, type: ${{ steps.build_package.outputs.level }}

Test a release

Runs semantic release in dry-run mode on a branch different to master, omitting to commit any assets or perform the actual release.

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      dry-run: true
      release-branches: '["my-branch"]'

Create a release to a different branch

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      release-branches: '["releases"]'

Create a pre-release release to a channel (e.g. "beta")

For pre-releases it is recommended to create a separate workflow: (e.g. continuous-delivery-beta.yaml) which will run only on beta branch:

on:
  push:
    branches:
      - beta

steps:
  - name: Beta release
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    uses: ridedott/release-me-action@master
    with:
      release-branches: '[{"name":"beta","prerelease":"beta"}]',
  - name: Setup Node.js
    uses: actions/setup-node@v1
    with:
      registry-url: "https://npm.pkg.github.com"
  - name: Publish to GitHub Packages
    env:
      NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN_WORKAROUND }}
    run: |
      npm publish --tag=beta

Create a release and update repository contents

Commit the listed glob patterns to the repository as part of the release process.

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      commit-assets: |
        ./dist
        ./public

Create a release with attached artifacts

Attach the listed glob patterns to the release.

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      release-assets: |
        ./generated/my-asset.tar.gz

Create a release updating an npm package version

This configuration also updates package.json and package-lock.json or yarn-lock.yaml files alongside CHANGELOG.md.

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      node-module: true

Create a release on a protected branch

This configuration uses a GitHub Personal Access Token to authenticate to GitHub.

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master

Create a release of a node module and publish it to multiple registries

This configuration showcases how to complement the release with publishing steps for multiple package registries.

steps:
  - env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Release
    uses: ridedott/release-me-action@master
    with:
      node-module: true
  - name: Setup Node.js
    uses: actions/setup-node@v1
    with:
      registry-url: 'https://npm.pkg.github.com'
  - env:
      NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Publish to GitHub Packages
    run: npm publish
  - name: Setup Node.js
    uses: actions/setup-node@v1
    with:
      registry-url: 'https://registry.npm.org'
      # Scoped packages require the scope parameter to be set in the setup
      # node step when publishing to the npm registry.
      scope: '@my-organization'
  - env:
      NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
    name: Publish to npm
    run: npm publish