Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

semantic-release/github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Build Status

npm latest versionnpm next versionnpm beta version

StepDescription
verifyConditionsVerify the presence and the validity of the authentication (set viaenvironment variables) and theassets option configuration.
publishPublish aGitHub release, optionally uploading file assets.
addChannelUpdate aGitHub release'spre-release field.
successAdd a comment to eachGitHub Issue orPull Request resolved by the release and close issues previously open by thefail step.
failOpen or update aGitHub Issue with information about the errors that caused the release to fail.

Install

Tip

You do not need to directly depend on this package if you are usingsemantic-release.semantic-release already depends on this package, and defining your own direct dependency can result in conflicts when you updatesemantic-release.

$ npm install @semantic-release/github -D

Usage

The plugin can be configured in thesemantic-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 exampleGitHub releases will be published with the filedist/asset.min.css anddist/asset.min.js.

Configuration

GitHub authentication

The GitHub authentication configuration isrequired and can be set viaenvironment variables.

Follow theCreating 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 theGH_TOKEN environment variable. The user associated with the token must have push permission to the repository.

When creating the token, theminimum required scopes are:

Note on GitHub Actions: You can use the default token which is provided in the secretGITHUB_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 theGITHUB_TOKEN, theminimum 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 orGH_TOKENRequired. The token used to authenticate with GitHub.
GITHUB_URL orGH_URLThe GitHub server endpoint.
GITHUB_PREFIX orGH_PREFIXThe GitHub API prefix, relative toGITHUB_URL.
GITHUB_API_URLThe GitHub API endpoint. Note that this overwritesGITHUB_PREFIX.

Options

OptionDescriptionDefault
githubUrlThe GitHub server endpoint.GH_URL orGITHUB_URL environment variable.
githubApiPathPrefixThe GitHub API prefix, relative togithubUrl.GH_PREFIX orGITHUB_PREFIX environment variable.
githubApiUrlThe GitHub API endpoint. Note that this overwritesgithubApiPathPrefix.GITHUB_API_URL environment variable.
proxyThe proxy to use to access the GitHub API. Set tofalse to disable usage of proxy. Seeproxy.HTTP_PROXY environment variable.
assetsAn array of files to upload to the release. Seeassets.-
successCommentThe comment to add to each issue and pull request resolved by the release. Set tofalse to disable commenting on issues and pull requests. SeesuccessComment.: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. SeesuccessCommentCondition-
failCommentThe content of the issue created when a release fails. Set tofalse to disable opening an issue when a release fails. SeefailComment.Friendly message with links tosemantic-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 tofalse 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. SeefailCommentCondition.-
labelsThelabels to add to the issue created when a release fails. Set tofalse to not add any label.['semantic-release']
assigneesTheassignees to add to the issue created when a release fails.-
releasedLabelsThelabels to add to each issue and pull request resolved by the release. Set tofalse to not add any label. SeereleasedLabels.['released<%= nextRelease.channel ? \ on @${nextRelease.channel}` : "" %>']-
addReleasesWill add release links to the GitHub Release. Can befalse,"bottom" or"top". SeeaddReleases.false
draftReleaseA boolean indicating if a GitHub Draft Release should be created instead of publishing an actual GitHub Release.false
releaseNameTemplateALodash template to customize the github release's name<%= nextverison.name %>
releaseBodyTemplateALodash template to customize the github release's body<%= nextverison.notes %>
discussionCategoryNameThe category name in which to create a linked discussion to the release. Set tofalse to disable creating discussion for a release.false

proxy

Can befalse, a proxy URL or anObject with the following properties:

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

Seenode-https-proxy-agent andnode-http-proxy-agent for additional details.

proxy examples

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

assets

Can be aglob or andArray ofglobs andObjects with the following properties:

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

Each entry in theassetsArray is globbed individually. Aglobcan be aString ("dist/**/*.js" or"dist/mylib.js") or anArray ofStrings that will be globbed together(["dist/**", "!**/*.css"]).

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

Thename andlabel for each assets are generated withLodash template. The following variables are available:

ParameterDescription
branchThe branch from which the release is done.
lastReleaseObject withversion,gitTag andgitHead of the last release.
nextReleaseObject withversion,gitTag,gitHead andnotes of the release being done.
commitsArray of commitObjects withhash,subject,bodymessage andauthor.

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

assets examples

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

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

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

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

[{path: 'dist/MyLibrary.js', name: 'MyLibrary-${nextRelease.gitTag}.js', label: 'MyLibrary JS (${nextRelease.gitTag}) distribution'}]: include the filedist/MyLibrary.js and upload it to the GitHub release with nameMyLibrary-v1.0.0.js and labelMyLibrary 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 withLodash template. The following variables are available:

ParameterDescription
branchObject withname,type,channel,range andprerelease properties of the branch from which the release is done.
lastReleaseObject withversion,channel,gitTag andgitHead of the last release.
nextReleaseObject withversion,channel,gitTag,gitHead andnotes of the release being done.
commitsArray of commitObjects withhash,subject,bodymessage andauthor.
releasesArray with a releaseObjects for each release published, with optional release data such asname andurl.
issueAGitHub API pull request object for pull requests related to a commit, orGitHub API issue object for issues resolved viakeywords
successComment example

ThesuccessCommentThis ${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

ALodash template string that should evaluate to a truthy or falsy variable. The following variables are available:

ParameterDescription
branchObject withname,type,channel,range andprerelease properties of the branch from which the release is done.
lastReleaseObject withversion,channel,gitTag andgitHead of the last release.
nextReleaseObject withversion,channel,gitTag,gitHead andnotes of the release being done.
commitsArray of commitObjects withhash,subject,bodymessage andauthor.
releasesArray with a releaseObjects for each release published, with optional release data such asname andurl.
issueAGitHub API Pull Request object for pull requests related to a commit
successCommentCondition example
  • do not create any comments at all: set tofalse 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 theGitHub API issue object for properties which can be used for the filter

failComment

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

ParameterDescription
branchThe branch from which the release had failed.
errorsAnArray ofSemanticReleaseError. Each error has themessage,code,pluginName anddetails 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

ThefailCommentThis 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

ALodash template string that should evaluate to a truthy or falsy variable. The following variables are available:

ParameterDescription
branchObject withname,type,channel,range andprerelease properties of the branch from which the release is done.
lastReleaseObject withversion,channel,gitTag andgitHead of the last release.
nextReleaseObject withversion,channel,gitTag,gitHead andnotes of the release being done.
commitsArray of commitObjects withhash,subject,bodymessage andauthor.
releasesArray with a releaseObjects for each release published, with optional release data such asname andurl.
issueAGitHub API pull request object for pull requests related to a commit, orGitHub API issue object for issues resolved viakeywords
failCommentCondition example
  • do not create any comments at all: set tofalse 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 withwip:"<% return !issue.labels?.includes('wip') %>"

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

releasedLabels

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

ParameterDescription
branchObject withname,type,channel,range andprerelease properties of the branch from which the release is done.
lastReleaseObject withversion,channel,gitTag andgitHead of the last release.
nextReleaseObject withversion,channel,gitTag,gitHead andnotes of the release being done.
commitsArray of commitObjects withhash,subject,bodymessage andauthor.
releasesArray with a releaseObjects for each release published, with optional release data such asname andurl.
issueAGitHub API pull request object for pull requests related to a commit, orGitHub API issue object for issues resolved viakeywords
releasedLabels example

ThereleasedLabels['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 arefalse,"top" or"bottom".

addReleases example

SeeThe introducing PR for an example on how it will look.

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors46


[8]ページ先頭

©2009-2025 Movatter.jp