Skip to content

Commit

Permalink
feat: Add githubReleaseAssets option
Browse files Browse the repository at this point in the history
Includes the addition of a new option githubReleaseAssets to replace the
old assets option. The assets option is identical to the option found in
the git plugin but is ambiguous when used in shared configuration
packages.

Fixes: #808
  • Loading branch information
esatterwhite committed Apr 17, 2024
1 parent eab4946 commit 8a17388
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
[
"@semantic-release/github",
{
"assets": [
"githubReleaseAssets": [
{ "path": "dist/asset.min.css", "label": "CSS distribution" },
{ "path": "dist/asset.min.js", "label": "JS distribution" }
]
Expand Down Expand Up @@ -80,11 +80,12 @@ When using the _GITHUB_TOKEN_, the **minimum required permissions** are:
### Options

| Option | Description | Default |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `githubUrl` | The GitHub Enterprise endpoint. | `GH_URL` or `GITHUB_URL` environment variable. |
| `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. |
| `proxy` | The proxy to use to access the GitHub API. Set to `false` to disable usage of proxy. See [proxy](#proxy). | `HTTP_PROXY` environment variable. |
| `assets` | An array of files to upload to the release. See [assets](#assets). | - |
| `githubReleaseAssets` | An array of files to upload to the release. See [githubReleaseAssets](#githubreleaseassets). | - |
| `assets` | (deprecated) An alias of [githubReleaseAssets](#githubreleaseassets). | - |
| `successComment` | The 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](#successcomment). | `:tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](<github_release_url>)` |
| `failComment` | The content of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. See [failComment](#failcomment). | Friendly message with links to **semantic-release** documentation and support, with the list of errors that caused the release to fail. |
| `failTitle` | The 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 🚨` |
Expand Down Expand Up @@ -115,7 +116,7 @@ See [node-https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-age
`'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
#### githubReleaseAssets

Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array` of
[globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties:
Expand All @@ -126,7 +127,7 @@ Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array`
| `name` | The name of the downloadable file on the GitHub release. | File name extracted from the `path`. |
| `label` | Short description of the file displayed on the GitHub release. | - |

Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
Each entry in the `githubReleaseAssets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together
(`["dist/**", "!**/*.css"]`).

Expand All @@ -141,9 +142,9 @@ The `name` and `label` for each assets are generated with [Lodash template](http
| `nextRelease` | `Object` with `version`, `gitTag`, `gitHead` and `notes` of the release being done. |
| `commits` | `Array` of commit `Object`s 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`.
**Note**: If a file has a match in `githubReleaseAssets` it will be included even if it also has a match in `.gitignore`.

##### assets examples
##### release assets examples

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

Expand Down
4 changes: 3 additions & 1 deletion lib/resolve-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function resolveConfig(
githubApiPathPrefix,
proxy,
assets,
githubReleaseAssets,
successComment,
failTitle,
failComment,
Expand All @@ -20,13 +21,14 @@ export default function resolveConfig(
},
{ env },
) {
const releaseAssets = githubReleaseAssets || assets;
return {
githubToken: env.GH_TOKEN || env.GITHUB_TOKEN,
githubUrl: githubUrl || env.GITHUB_API_URL || env.GH_URL || env.GITHUB_URL,
githubApiPathPrefix:
githubApiPathPrefix || env.GH_PREFIX || env.GITHUB_PREFIX || "",
proxy: isNil(proxy) ? env.http_proxy || env.HTTP_PROXY || false : proxy,
assets: assets ? castArray(assets) : assets,
assets: releaseAssets ? castArray(releaseAssets) : releaseAssets,
successComment,
failTitle: isNil(failTitle)
? "The automated release is failing 🚨"
Expand Down
2 changes: 1 addition & 1 deletion test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ test("Publish a draft release with one asset", async (t) => {
const repo = "test_repo";
const env = { GITHUB_TOKEN: "github_token" };
const pluginConfig = {
assets: [
githubReleaseAssets: [
["**", "!**/*.txt"],
{ path: ".dotfile", label: "A dotfile with no ext" },
],
Expand Down

0 comments on commit 8a17388

Please sign in to comment.