11.0.0 • Published 2 months ago

@semantic-release/github v11.0.0

Weekly downloads
378,051
License
MIT
Repository
github
Last release
2 months ago

@semantic-release/github

semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues.

Build Status

npm latest version npm next version npm beta version

StepDescription
verifyConditionsVerify the presence and the validity of the authentication (set via environment variables) and the assets option configuration.
publishPublish a GitHub release, optionally uploading file assets.
addChannelUpdate a GitHub release's pre-release field.
successAdd a comment to each GitHub Issue or Pull Request resolved by the release and close issues previously open by the fail step.
failOpen or update a GitHub Issue with information about the errors that caused the release to fail.

Install

$ npm install @semantic-release/github -D

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/github",
      {
        "assets": [
          { "path": "dist/asset.min.css", "label": "CSS distribution" },
          { "path": "dist/asset.min.js", "label": "JS distribution" }
        ]
      }
    ]
  ]
}

With this example GitHub releases will be published with the file dist/asset.min.css and dist/asset.min.js.

Configuration

GitHub authentication

The GitHub authentication configuration is required and can be set via environment variables.

Follow the Creating a personal access token for the command line documentation to obtain an authentication token. The token has to be made available in your CI environment via the GH_TOKEN environment variable. The user associated with the token must have push permission to the repository.

When creating the token, the minimum required scopes are:

Note on GitHub Actions: You can use the default token which is provided in the secret GITHUB_TOKEN. However releases done with this token will NOT trigger release events to start other workflows. If you have actions that trigger on newly created releases, please use a generated token for that and store it in your repository's secrets (any other name than GITHUB_TOKEN is fine).

When using the GITHUB_TOKEN, the minimum required permissions are:

  • contents: write to be able to publish a GitHub release
  • issues: write to be able to comment on released issues
  • pull-requests: write to be able to comment on released pull requests

Environment variables

VariableDescription
GITHUB_TOKEN or GH_TOKENRequired. The token used to authenticate with GitHub.
GITHUB_URL or GH_URLThe GitHub server endpoint.
GITHUB_PREFIX or GH_PREFIXThe GitHub API prefix, relative to GITHUB_URL.
GITHUB_API_URLThe GitHub API endpoint. Note that this overwrites GITHUB_PREFIX.

Options

OptionDescriptionDefault
githubUrlThe GitHub server endpoint.GH_URL or GITHUB_URL environment variable.
githubApiPathPrefixThe GitHub API prefix, relative to githubUrl.GH_PREFIX or GITHUB_PREFIX environment variable.
githubApiUrlThe GitHub API endpoint. Note that this overwrites githubApiPathPrefix.GITHUB_API_URL environment variable.
proxyThe proxy to use to access the GitHub API. Set to false to disable usage of proxy. See proxy.HTTP_PROXY environment variable.
assetsAn array of files to upload to the release. See assets.-
successCommentThe comment to add to each issue and pull request resolved by the release. Set to false to disable commenting on issues and pull requests. See successComment.:tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](<github_release_url>)
successCommentConditionUse this as condition, when to comment on issues or pull requests. See successCommentCondition-
failCommentThe content of the issue created when a release fails. Set to false to disable opening an issue when a release fails. See failComment.Friendly message with links to semantic-release documentation and support, with the list of errors that caused the release to fail.
failTitleThe title of the issue created when a release fails. Set to false to disable opening an issue when a release fails.The automated release is failing 🚨
failCommentConditionUse this as condition, when to comment on or create an issues in case of failures. See failCommentCondition.-
labelsThe labels to add to the issue created when a release fails. Set to false to not add any label.['semantic-release']
assigneesThe assignees to add to the issue created when a release fails.-
releasedLabelsThe labels to add to each issue and pull request resolved by the release. Set to false to not add any label. See releasedLabels.['released<%= nextRelease.channel ? \ on @\${nextRelease.channel}` : "" %>']-
addReleasesWill add release links to the GitHub Release. Can be false, "bottom" or "top". See addReleases.false
draftReleaseA boolean indicating if a GitHub Draft Release should be created instead of publishing an actual GitHub Release.false
releaseNameTemplateA Lodash template to customize the github release's name<%= nextverison.name %>
releaseBodyTemplateA Lodash template to customize the github release's body<%= nextverison.notes %>
discussionCategoryNameThe category name in which to create a linked discussion to the release. Set to false to disable creating discussion for a release.false

proxy

Can be false, a proxy URL or an Object with the following properties:

PropertyDescriptionDefault
hostRequired. Proxy host to connect to.-
portRequired. Proxy port to connect to.File name extracted from the path.
secureProxyIf true, then use TLS to connect to the proxy.false
headersAdditional HTTP headers to be sent on the HTTP CONNECT method.-

See node-https-proxy-agent and node-http-proxy-agent for additional details.

proxy examples

'http://168.63.76.32:3128': use the proxy running on host 168.63.76.32 and port 3128 for each GitHub API request. {host: '168.63.76.32', port: 3128, headers: {Foo: 'bar'}}: use the proxy running on host 168.63.76.32 and port 3128 for each GitHub API request, setting the Foo header value to bar.

assets

Can be a glob or and Array of globs and Objects with the following properties:

PropertyDescriptionDefault
pathRequired. A glob to identify the files to upload.-
nameThe name of the downloadable file on the GitHub release.File name extracted from the path.
labelShort description of the file displayed on the GitHub release.-

Each entry in the assets Array is globbed individually. A glob can be a String ("dist/**/*.js" or "dist/mylib.js") or an Array of Strings that will be globbed together (["dist/**", "!**/*.css"]).

If a directory is configured, all the files under this directory and its children will be included.

The name and label for each assets are generated with Lodash template. The following variables are available:

ParameterDescription
branchThe branch from which the release is done.
lastReleaseObject with version, gitTag and gitHead of the last release.
nextReleaseObject with version, gitTag, gitHead and notes of the release being done.
commitsArray of commit Objects with hash, subject, body message and author.

Note: If a file has a match in assets it will be included even if it also has a match in .gitignore.

assets examples

'dist/*.js': include all the js files in the dist directory, but not in its sub-directories.

[['dist', '!**/*.css']]: include all the files in the dist directory and its sub-directories excluding the css files.

[{path: 'dist/MyLibrary.js', label: 'MyLibrary JS distribution'}, {path: 'dist/MyLibrary.css', label: 'MyLibrary CSS distribution'}]: include the dist/MyLibrary.js and dist/MyLibrary.css files, and label them MyLibrary JS distribution and MyLibrary CSS distribution in the GitHub release.

[['dist/**/*.{js,css}', '!**/*.min.*'], {path: 'build/MyLibrary.zip', label: 'MyLibrary'}]: include all the js and css files in the dist directory and its sub-directories excluding the minified version, plus the build/MyLibrary.zip file and label it MyLibrary in the GitHub release.

[{path: 'dist/MyLibrary.js', name: 'MyLibrary-${nextRelease.gitTag}.js', label: 'MyLibrary JS (${nextRelease.gitTag}) distribution'}]: include the file dist/MyLibrary.js and upload it to the GitHub release with name MyLibrary-v1.0.0.js and label MyLibrary JS (v1.0.0) distribution which will generate the link:

[MyLibrary JS (v1.0.0) distribution](MyLibrary-v1.0.0.js)

successComment

The message for the issue comments is generated with Lodash template. The following variables are available:

ParameterDescription
branchObject with name, type, channel, range and prerelease properties of the branch from which the release is done.
lastReleaseObject with version, channel, gitTag and gitHead of the last release.
nextReleaseObject with version, channel, gitTag, gitHead and notes of the release being done.
commitsArray of commit Objects with hash, subject, body message and author.
releasesArray with a release Objects for each release published, with optional release data such as name and url.
issueA GitHub API pull request object for pull requests related to a commit, or GitHub API issue object for issues resolved via keywords
successComment example

The successComment This ${issue.pull_request ? 'pull request' : 'issue'} is included in version ${nextRelease.version} will generate the comment:

This pull request is included in version 1.0.0

successCommentCondition

The message for the issue comments is generated with Lodash template. The following variables are available:

ParameterDescription
branchObject with name, type, channel, range and prerelease properties of the branch from which the release is done.
lastReleaseObject with version, channel, gitTag and gitHead of the last release.
nextReleaseObject with version, channel, gitTag, gitHead and notes of the release being done.
commitsArray of commit Objects with hash, subject, body message and author.
releasesArray with a release Objects for each release published, with optional release data such as name and url.
issueA GitHub API Pull Request object for pull requests related to a commit
successCommentCondition example
  • do not create any comments at all: set to false or templating: "<% return false; %>"
  • to only comment on issues: "<% return !issue.pull_request; %>"
  • to only comment on pull requests: "<% return issue.pull_request; %>"
  • to avoid comment on PRs or issues created by Bots: "<% return issue.user.type !== 'Bot'; %>"
  • you can use labels to filter issues: "<% return issue.labels?.some((label) => { return label.name === ('semantic-release-relevant'); }); %>"

check the GitHub API issue object for properties which can be used for the filter

failComment

The message for the issue content is generated with Lodash template. The following variables are available:

ParameterDescription
branchThe branch from which the release had failed.
errorsAn Array of SemanticReleaseError. Each error has the message, code, pluginName and details properties.pluginName contains the package name of the plugin that threw the error.details contains a information about the error formatted in markdown.
failComment example

The failComment This release from branch ${branch.name} had failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} will generate the comment:

This release from branch master had failed due to the following errors:

  • Error message 1
  • Error message 2

failCommentCondition

The message for the issue content is generated with Lodash template. The following variables are available:

ParameterDescription
branchObject with name, type, channel, range and prerelease properties of the branch from which the release is done.
lastReleaseObject with version, channel, gitTag and gitHead of the last release.
nextReleaseObject with version, channel, gitTag, gitHead and notes of the release being done.
commitsArray of commit Objects with hash, subject, body message and author.
releasesArray with a release Objects for each release published, with optional release data such as name and url.
issueA GitHub API pull request object for pull requests related to a commit, or GitHub API issue object for issues resolved via keywords
failCommentCondition example
  • do not create any comments at all: set to false or templating: "<% return false; %>"
  • to only comment on main branch: "<% return branch.name === 'main' %>"
  • you can use labels to filter issues, i.e. to not comment if the issue is labeled with wip: "<% return !issue.labels?.includes('wip') %>"

check the GitHub API Pull Request Object for properties which can be used for the filter

releasedLabels

Each label name is generated with Lodash template. The following variables are available:

ParameterDescription
branchObject with name, type, channel, range and prerelease properties of the branch from which the release is done.
lastReleaseObject with version, channel, gitTag and gitHead of the last release.
nextReleaseObject with version, channel, gitTag, gitHead and notes of the release being done.
commitsArray of commit Objects with hash, subject, body message and author.
releasesArray with a release Objects for each release published, with optional release data such as name and url.
issueA GitHub API pull request object for pull requests related to a commit, or GitHub API issue object for issues resolved via keywords
releasedLabels example

The releasedLabels ['released<%= nextRelease.channel ? ` on @\${nextRelease.channel}` : "" %> from <%= branch.name %>'] will generate the label:

released on @next from branch next

addReleases

Add links to other releases to the GitHub release body.

Valid values for this option are false, "top" or "bottom".

addReleases example

See The introducing PR for an example on how it will look.

@sergeyzwezdin/semantic-release-configtrippkit@lansweeper/semantic-release-config@droplt/core@ahmadnassri/semantic-release-config@esatterwhite/semantic-release-dockersemantic-github-pullrequest@educationperfect/semantic-release@ahmadnassri/semantic-release@coobeet/semantic-release-configusecsv-plugintest-semantic-release-yakovlevyuri-2@wishlez/semantic-release@araclx/semantic-release@infinitebrahmanuniverse/nolb-_sema@adfinis-sygroup/semantic-release-config@everything-registry/sub-chunk-818@healform/liquidt1t4n-releasevue-material-3semantic-commitlintsemantic-release-squashsemantic-release-squash3semantic-release-tsheets-testsemantic-release-upload-gcrsemantic-release-wo-notessemantic-release-wordpress-configsemantic-release-ramkraosemantic-release-preconfigured-conventional-commitssemantic-release-pulsar-configscratch-semantic-release-configscreepers-steamless-clientstarwars-names-kshzhtemp-semantic-release-debugtemp-test-semantic-releasespire-plugin-semantic-releasesemantic-release-github-pullrequestsemantic-release-config-aristeksemantic-release-config-bitworkerssemantic-release-config-fabulatorsemantic-release-config-gitmojisemantic-release-expo-npm-github-publishsemantic-releasesemantic-release-flexsemantic-release-npm-githubsemantic-release-plussemantic-release-jira-lister@joshunrau/semantic-release-configvelqui@esatterwhite/eslint-config-reasonablegithub-testinggrooveshop-media-streamjm-my-storybook-componentsibm-sccist-user-experienceinnostark-design-systemhl2biffe-commitihau-bid-expiration-materializergh-release-test-actiongithub-workflow-managermonorepo-semantic-releaselvbyte-cdnmaxweldsouza-test-reponodejs-env-checkeropen-sauced-semantic-config-testpraesentiumsapientepsivasemantic-releasenpmzulupresets-lint-testraw-vs-rendered-htmlqallidi-ui-componentssr-gh-studyssh-dev-scriptstravis-semantic-release@anycli/semantic-release@armor/semantic-release@as-radek/react-native-document-scanner@anolilab/semantic-release-preset@atir-naveed-geeksltd/semantic-release-config@atom-ide-community/semantic-release-npm-config@alanscodelog/semantic-release-config@alexarts74/package-upload-wa-map@beecode/msh-config@bizon/semantic-release-config@betahuhn/config@bgdanix/semrls@bubojs/sequelize@bubojs/uploader-firebase@catalystsquad/release-config-composite-actions@catalystsquad/release-config-general@catalystsquad/release-config-helm@catalystsquad/release-config-javascript-actions@catalystsquad/release-config-npm-no-publish@catalystsquad/release-config-template@catchfashion/semantic-release-config@byte-craft-react/semantic-release-config@cablanchard/semantic-release@brezel/semantic-release@citadel2024/team-lint
11.0.0

2 months ago

10.0.5

6 months ago

10.0.6

6 months ago

10.0.7

5 months ago

10.3.2

3 months ago

10.3.3

3 months ago

10.3.4

2 months ago

10.3.5

2 months ago

10.3.0

3 months ago

10.3.1

3 months ago

10.2.0

3 months ago

10.1.4

4 months ago

10.1.5

3 months ago

10.1.6

3 months ago

10.1.7

3 months ago

10.1.0

5 months ago

10.1.1

4 months ago

10.1.2

4 months ago

10.1.3

4 months ago

10.0.4

6 months ago

10.0.3

8 months ago

10.0.0

8 months ago

10.0.1

8 months ago

10.0.2

8 months ago

9.2.6

11 months ago

9.2.5

12 months ago

9.0.7

1 year ago

9.0.6

1 year ago

9.0.5

1 year ago

9.0.4

1 year ago

9.2.4

12 months ago

9.2.3

1 year ago

9.2.2

1 year ago

9.2.1

1 year ago

9.1.0

1 year ago

9.2.0

1 year ago

9.0.3

1 year ago

8.1.0

1 year ago

9.0.0-beta.2

1 year ago

9.0.0-beta.1

1 year ago

9.0.2

1 year ago

9.0.1

1 year ago

9.0.0

1 year ago

8.0.9

1 year ago

8.0.8

1 year ago

8.0.7

2 years ago

8.0.6

2 years ago

8.0.5

2 years ago

8.0.4

3 years ago

8.0.3

3 years ago

8.0.2

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.0-beta.1

3 years ago

7.2.3

4 years ago

7.2.2

4 years ago

7.2.1

4 years ago

7.2.0

4 years ago

7.1.2

4 years ago

7.1.1

4 years ago

7.1.0

4 years ago

7.0.7

5 years ago

7.0.6

5 years ago

7.0.5

5 years ago

7.0.4

5 years ago

7.0.3

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.0.2

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

5.6.0-beta.7

5 years ago

5.5.8

5 years ago

5.5.7

5 years ago

5.6.0-beta.6

5 years ago

6.0.0-beta.1

5 years ago

5.6.0-beta.5

5 years ago

5.6.0-beta.4

5 years ago

5.6.0-beta.3

5 years ago

5.5.6

5 years ago

5.5.5

5 years ago

5.5.4

5 years ago

5.5.3

5 years ago

5.6.0-beta.2

5 years ago

5.5.2

5 years ago

5.5.1

5 years ago

5.6.0-beta.1

5 years ago

5.5.0

5 years ago

5.4.4

5 years ago

5.4.3

5 years ago

5.4.2

5 years ago

5.5.0-beta.1

5 years ago

5.4.1

5 years ago

5.4.0

5 years ago

5.3.5

5 years ago

5.3.4

5 years ago

5.3.3

6 years ago

5.4.0-beta.1

6 years ago

5.3.2

6 years ago

5.3.1

6 years ago

5.3.0

6 years ago

5.2.12

6 years ago

5.2.11

6 years ago

5.3.0-beta.8

6 years ago

5.2.10

6 years ago

5.2.9

6 years ago

5.3.0-beta.7

6 years ago

5.3.0-beta.6

6 years ago

5.2.8

6 years ago

5.3.0-beta.5

6 years ago

5.3.0-beta.4

6 years ago

5.3.0-beta.3

6 years ago

5.2.7

6 years ago

5.3.0-beta.2

6 years ago

5.2.6

6 years ago

5.3.0-beta.1

6 years ago

5.2.5

6 years ago

5.2.4

6 years ago

5.2.3

6 years ago

5.2.2

6 years ago

5.2.1

6 years ago

5.2.0

6 years ago

5.1.0

6 years ago

5.0.6

6 years ago

5.0.5

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.4.2

6 years ago

4.4.1

6 years ago

4.4.0

6 years ago

4.3.0

6 years ago

4.2.18

6 years ago

4.2.17

6 years ago

4.2.16

7 years ago

4.2.15

7 years ago

4.2.14

7 years ago

4.2.13

7 years ago

4.2.12

7 years ago

4.2.11

7 years ago

4.2.10

7 years ago

4.2.9

7 years ago

4.2.8

7 years ago

4.2.7

7 years ago

4.2.6

7 years ago

4.2.5

7 years ago

4.2.4

7 years ago

4.2.3

7 years ago

4.2.2

7 years ago

4.2.1

7 years ago

4.2.0

7 years ago

4.1.3

7 years ago

4.1.2

7 years ago

4.1.1

7 years ago

4.1.0

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago