Skip to content

This GitHub action automatically creates a release in a PR and, after merging, publishes your package to the supported package registry and notifies you of the release in Slack.

Notifications You must be signed in to change notification settings

DXHeroes/gh-action-auto-release

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub release (with filter)

GH Action Auto Release v1.0.8

Time to implement: 10 minutes.

Saved time: 1 hour per each release of any technology.

This GitHub Action will automatically create a release and publish your package to the supported package registry.

How it works

This action uses release-please under the hood. It will create a pull request with the release notes and you can check them before merging.

When you merge the pull request, it will create a release with the release notes from the pull request.

Each release will be tagged with a version from the commit message. You can use conventional commits or just add a version number to the commit message.

Every release will be published to the supported package registry.

You can get your package published in a few minutes and you won't have to worry about it anymore. Just follow the instructions below and you're done.

Supported package types

  • ✅ node
  • ✅ php
  • ✅ ruby

Please request other package types in the issues

  • 🛠️ .NET
  • 🛠️ dart
  • 🛠️ elixir
  • 🛠️ go
  • 🛠️ helm
  • 🛠️ java
  • 🛠️ maven
  • 🛠️ krm-blueprint
  • 🛠️ maven
  • 🛠️ expo
  • 🛠️ ocaml
  • 🛠️ python
  • 🛠️ rust
  • 🛠️ sfdx
  • 🛠️ simple
  • 🛠️ terraform-module

Prerequisites

GitHub Actions

You must allow GitHub actions to create and approve pull requests. You can do this in the organization or repository settings.

Node.js package

Add these secret to your repository:

  • name: NPM_TOKEN - NPM token with write access to the package.
    • Required permissions for Granular Access Token: Packages and scopes > 'Read and write'.
    • Required permissions for Classic Token: 'Automation'.

PHP package

Add these secrets to your repository:

Ruby package

Add these secret to your repository:

  • name: RUBYGEMS_API_KEY - RubyGems API key with write access to the package.
    • Required scope: 'Push rubygem'.

Usage

Create your GitHub Action

Create a new file in your repository .github/workflows/release.yml with the following content that fits your package type.

For Node.js package

name: Release
on:
  push:
    branches:
      - main # set your default branch

permissions:
  contents: write
  pull-requests: write

jobs:
  release:
    name: Release by DX Heroes
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dxheroes/gh-action-auto-release@v1
        with:
          release-type: node
          package-name: prs-test-js-lib # replace with your package name
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

For PHP package

name: Release
on:
  push:
    branches:
      - main # set your default branch

permissions:
  contents: write
  pull-requests: write

jobs:
  release:
    name: Release by DX Heroes
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dxheroes/gh-action-auto-release@v1
        with:
          release-type: php
          package-name: prs-test-php-lib
        env:
          PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }}
          PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}

For Ruby package

name: Release
on:
  push:
    branches:
      - main # set your default branch

permissions:
  contents: write
  pull-requests: write

jobs:
  release:
    name: Release by DX Heroes
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dxheroes/gh-action-auto-release@v1
        with:
          release-type: ruby
          package-name: prs-test-ruby-lib
        env:
          RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}

Advanced usage

Arguments for the action

  • release-type - Type of the release. Default: node
  • package-name - Name of the package. Required.
  • You can also set other release-please arguments. See release-please documentation for more information.

Get notified about new releases

Slack

Just add this env variable to your workflow:

env:
  SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Please request other platforms in the issues

Example of setting up Slack notifications for node.js package:

name: Release
on:
  push:
    branches:
      - main # set your default branch

permissions:
  contents: write
  pull-requests: write

jobs:
  release:
    name: Release by DX Heroes
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dxheroes/gh-action-auto-release@v1
        with:
          release-type: node
          package-name: prs-test-js-lib # replace with your package name
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} ## Configure SLACK_WEBHOOK_URL

Customize package path when using monorepo or is not in the root directory

Set working-directory to the path of the package. For example:

name: Release
on:
  push:
    branches:
      - main # set your default branch

permissions:
  contents: write
  pull-requests: write

jobs:
  release:
    name: Release by DX Heroes
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: libraries/js-lib # replace with your package path
    steps:
      # ...

Contributing

All contributions are welcome. Please create an issue or submit a pull request.

About

This GitHub action automatically creates a release in a PR and, after merging, publishes your package to the supported package registry and notifies you of the release in Slack.

Topics

Resources

Stars

Watchers

Forks