Skip to content

Commit 1aed3e4

Browse files
committed
feat: Add githubReleaseAssets option
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: semantic-release#808
1 parent bccd140 commit 1aed3e4

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
3535
[
3636
"@semantic-release/github",
3737
{
38-
"assets": [
38+
"githubReleaseAssets": [
3939
{ "path": "dist/asset.min.css", "label": "CSS distribution" },
4040
{ "path": "dist/asset.min.js", "label": "JS distribution" }
4141
]
@@ -80,11 +80,12 @@ When using the _GITHUB_TOKEN_, the **minimum required permissions** are:
8080
### Options
8181

8282
| Option | Description | Default |
83-
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
83+
|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
8484
| `githubUrl` | The GitHub Enterprise endpoint. | `GH_URL` or `GITHUB_URL` environment variable. |
8585
| `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. |
8686
| `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. |
87-
| `assets` | An array of files to upload to the release. See [assets](#assets). | - |
87+
| `githubReleaseAssets` | An array of files to upload to the release. See [githubReleaseAssets](#githubreleaseassets). | - |
88+
| `assets` | (deprecated) An alias of [githubReleaseAssets](#githubreleaseassets). | - |
8889
| `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>)` |
8990
| `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. |
9091
| `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 🚨` |
@@ -115,7 +116,7 @@ See [node-https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-age
115116
`'http://168.63.76.32:3128'`: use the proxy running on host `168.63.76.32` and port `3128` for each GitHub API request.
116117
`{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`.
117118

118-
#### assets
119+
#### githubReleaseAssets
119120

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

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

@@ -141,9 +142,9 @@ The `name` and `label` for each assets are generated with [Lodash template](http
141142
| `nextRelease` | `Object` with `version`, `gitTag`, `gitHead` and `notes` of the release being done. |
142143
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
143144

144-
**Note**: If a file has a match in `assets` it will be included even if it also has a match in `.gitignore`.
145+
**Note**: If a file has a match in `githubReleaseAssets` it will be included even if it also has a match in `.gitignore`.
145146

146-
##### assets examples
147+
##### release assets examples
147148

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

lib/resolve-config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default function resolveConfig(
66
githubApiPathPrefix,
77
proxy,
88
assets,
9+
githubReleaseAssets,
910
successComment,
1011
failTitle,
1112
failComment,
@@ -20,13 +21,14 @@ export default function resolveConfig(
2021
},
2122
{ env },
2223
) {
24+
const releaseAssets = githubReleaseAssets || assets;
2325
return {
2426
githubToken: env.GH_TOKEN || env.GITHUB_TOKEN,
2527
githubUrl: githubUrl || env.GITHUB_API_URL || env.GH_URL || env.GITHUB_URL,
2628
githubApiPathPrefix:
2729
githubApiPathPrefix || env.GH_PREFIX || env.GITHUB_PREFIX || "",
2830
proxy: isNil(proxy) ? env.http_proxy || env.HTTP_PROXY || false : proxy,
29-
assets: assets ? castArray(assets) : assets,
31+
assets: releaseAssets ? castArray(releaseAssets) : releaseAssets,
3032
successComment,
3133
failTitle: isNil(failTitle)
3234
? "The automated release is failing 🚨"

test/publish.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ test("Publish a draft release with one asset", async (t) => {
820820
const repo = "test_repo";
821821
const env = { GITHUB_TOKEN: "github_token" };
822822
const pluginConfig = {
823-
assets: [
823+
githubReleaseAssets: [
824824
["**", "!**/*.txt"],
825825
{ path: ".dotfile", label: "A dotfile with no ext" },
826826
],

0 commit comments

Comments
 (0)