5
0
Fork 0
mirror of https://github.com/cycjimmy/semantic-release-action.git synced 2025-11-07 10:46:56 +00:00
GitHub Action for Semantic Release
Find a file
2020-03-21 22:50:51 +08:00
.github ci: fix id 2020-03-21 22:50:51 +08:00
docs chore(release): 2.3.0 [skip ci] 2020-03-21 09:38:18 +00:00
src feat(branches): support branches of semantic-release v16+ 2020-03-21 16:47:29 +08:00
.editorconfig feat: come a new action 2019-10-17 19:27:21 +08:00
.gitattributes Initial commit 2019-10-17 09:28:19 +08:00
.gitignore chore: update gitignore 2020-03-21 10:25:23 +08:00
.npmignore feat: come a new action 2019-10-17 19:27:21 +08:00
action.yml feat(branches): support branches of semantic-release v16+ 2020-03-21 16:47:29 +08:00
CODE_OF_CONDUCT.md feat: come a new action 2019-10-17 19:27:21 +08:00
index.js feat: come a new action 2019-10-17 19:27:21 +08:00
LICENSE chore(*): update LICENSE 2020-03-21 09:41:35 +08:00
package-lock.json chore(release): 2.3.0 [skip ci] 2020-03-21 09:38:18 +00:00
package.json chore(release): 2.3.0 [skip ci] 2020-03-21 09:38:18 +00:00
README.md docs(*): improve documentation for branches 2020-03-21 17:28:54 +08:00
release.config.js build(dependencies): use commitizen 2019-10-21 11:07:06 +08:00

Semantic Release Action

semantic-release npm license

GitHub Action for Semantic Release.

Usage

Step1: Set any Semantic Release Configuration in your repository.

Step2: Add Secrets in your repository for the Semantic Release Authentication Environment Variables.

Step3: Add a Workflow File to your repository to create custom automated processes.

  • inputs:
    • semantic_version: [Optional] Specify specifying version range for semantic-release. If no version range is specified, latest version will be used by default.
    • branches: [Optional] The branches on which releases should happen. It will override the branches attribute in your configuration file. If the attribute is not configured on both sides, the default is ['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]. Support for semantic-release above v16. See https://semantic-release.gitbook.io/semantic-release/usage/configuration#branches for more information.
    • branch: [Optional] The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master. Support for semantic-release older than v16.
    • extra_plugins: [Optional] Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.
    • dry_run: [Optional] Whether to run semantic release in dry-run mode. It will override the dryRun attribute in your configuration file.
  • outputs:
    • new_release_published: Whether a new release was published. true or false
    • new_release_version: Version of the new release
    • new_release_major_version: Major version of the new release
    • new_release_minor_version: Minor version of the new release
    • new_release_patch_version: Patch version of the new release
    • new_release_notes: The release notes for the new release.

Examples

A simple example

steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Semantic Release
    uses: cycjimmy/semantic-release-action@v2
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Setting semantic_version and branch | branches manually

It is recommended to specify specifying version range for semantic-release. If no version range is specified, latest version will be used by default.

steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Semantic Release
    uses: cycjimmy/semantic-release-action@v2
    with:
      semantic_version: 15.13.28  # It is recommended to specify specifying version range
                                  # for semantic-release.
      branch: master              # you can set branch for semantic-release older than v16.
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Semantic Release
    uses: cycjimmy/semantic-release-action@v2
    with:
      semantic_version: 16
      # you can set branches for semantic-release above v16.
      branches: |    
        [
          '+([0-9])?(.{+([0-9]),x}).x',
          'master', 
          'next', 
          'next-major', 
          {
            name: 'beta', 
            prerelease: true
          }, 
          {
            name: 'alpha', 
            prerelease: true
          }
        ]
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Passing Extra Plugins with extra_plugins

The action can be used with extra_plugins option to specify plugins which are not in the default list of plugins of semantic release. When using this option, please make sure that these plugins are also mentioned in your semantic release config's plugins array. For example, if you want to use @semantic-release/git and @semantic-release/changelog extra plugins, these must be added to extra_plugins in your actions file and plugins in your release config file as shown bellow:

github-action

steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Semantic Release
    uses: cycjimmy/semantic-release-action@v2
    with:
      # You can specify specifying version range for the extra plugins if you prefer.
      extra_plugins: |
        @semantic-release/changelog@3.0.0
        @semantic-release/git        
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

release-config

  plugins: [
    .
    .
+   "@semantic-release/changelog"
+   "@semantic-release/git",
  ]

Manually Specify a Version of Semantic-release and Its Plugins

It is recommended to manually specify a version of semantic-release and its plugins to prevent errors caused during the official semantic-release upgrade.

steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Semantic Release
    uses: cycjimmy/semantic-release-action@v2
    with:
      semantic_version: 15.14.0
      extra_plugins: |
        @semantic-release/git@7.0.18        
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Using Output Variables

steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Semantic Release
    uses: cycjimmy/semantic-release-action@v2
    id: semantic   # Need an `id` for output variables
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      
  - name: Do something when a new release published
    if: steps.semantic.outputs.new_release_published == 'true'
    run: echo ${{ steps.semantic.outputs.new_release_version }}

CHANGELOG