Skip to content

Commit 416fb56

Browse files
committed
Merge branch 'master' into beta
2 parents ea305db + 8503939 commit 416fb56

12 files changed

+113
-48
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: node_js
22

33
node_js:
4+
- 12
45
- 10
5-
- 8
6+
- 8.3
67

78
# Trigger a push build on release and greenkeeper branches + PRs build on every branches
89
# Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147)

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| `publish` | Publish a [GitHub release](https://help.github.com/articles/about-releases), optionally uploading file assets. |
1818
| `addChannel` | Update a [GitHub release](https://help.github.com/articles/about-releases)'s `pre-release` field. |
1919
| `success` | Add a comment to each [GitHub Issue](https://help.github.com/articles/about-issues) or [Pull Request](https://help.github.com/articles/about-pull-requests) resolved by the release and close issues previously open by the `fail` step. |
20-
| `fail` | Open or update a [GitHub Issue](https://help.github.com/articles/about-issues) with informations about the errors that caused the release to fail. |
20+
| `fail` | Open or update a [GitHub Issue](https://help.github.com/articles/about-issues) with information about the errors that caused the release to fail. |
2121

2222
## Install
2323

@@ -117,6 +117,15 @@ can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `Stri
117117

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

120+
The `name` and `label` for each assets are generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
121+
122+
| Parameter | Description |
123+
|---------------|-------------------------------------------------------------------------------------|
124+
| `branch` | The branch from which the release is done. |
125+
| `lastRelease` | `Object` with `version`, `gitTag` and `gitHead` of the last release. |
126+
| `nextRelease` | `Object` with `version`, `gitTag`, `gitHead` and `notes` of the release being done. |
127+
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
128+
120129
**Note**: If a file has a match in `assets` it will be included even if it also has a match in `.gitignore`.
121130

122131
##### assets examples
@@ -134,6 +143,10 @@ distribution` and `MyLibrary CSS distribution` in the GitHub release.
134143
`css` files in the `dist` directory and its sub-directories excluding the minified version, plus the
135144
`build/MyLibrary.zip` file and label it `MyLibrary` in the GitHub release.
136145

146+
`[{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:
147+
148+
> `[MyLibrary JS (v1.0.0) distribution](MyLibrary-v1.0.0.js)`
149+
137150
#### successComment
138151

139152
The message for the issue comments is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
@@ -157,10 +170,10 @@ The `successComment` `This ${issue.pull_request ? 'pull request' : 'issue'} is i
157170

158171
The message for the issue content is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
159172

160-
| Parameter | Description |
161-
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
162-
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. |
163-
| `errors` | An `Array` of [SemanticReleaseError](https://github.com/semantic-release/error). Each error has the `message`, `code`, `pluginName` and `details` properties.<br>`pluginName` contains the package name of the plugin that threw the error.<br>`details` contains a informations about the error formatted in markdown. |
173+
| Parameter | Description |
174+
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
175+
| `branch` | The branch from which the release had failed. |
176+
| `errors` | An `Array` of [SemanticReleaseError](https://github.com/semantic-release/error). Each error has the `message`, `code`, `pluginName` and `details` properties.<br>`pluginName` contains the package name of the plugin that threw the error.<br>`details` contains a information about the error formatted in markdown. |
164177

165178
##### failComment example
166179

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint require-atomic-updates: off */
2+
13
const {defaultTo, castArray} = require('lodash');
24
const verifyGitHub = require('./lib/verify');
35
const addChannelGitHub = require('./lib/add-channel');

lib/add-channel.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = async (pluginConfig, context) => {
1616
const {githubToken, githubUrl, githubApiPathPrefix, proxy} = resolveConfig(pluginConfig, context);
1717
const {name: repo, owner} = parseGithubUrl(repositoryUrl);
1818
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
19-
let release_id;
19+
let releaseId;
2020

2121
const release = {owner, repo, name, prerelease: isPrerelease(branch)};
2222

@@ -28,7 +28,7 @@ module.exports = async (pluginConfig, context) => {
2828

2929
try {
3030
({
31-
data: {id: release_id},
31+
data: {id: releaseId},
3232
} = await github.repos.getReleaseByTag({owner, repo, tag: currentGitTag}));
3333
} catch (error) {
3434
if (error.status === 404) {
@@ -47,14 +47,14 @@ module.exports = async (pluginConfig, context) => {
4747
throw error;
4848
}
4949

50-
const tag_name = currentChannel ? gitTag : undefined;
50+
const tagName = currentChannel ? gitTag : undefined;
5151

52-
debug('release release_id: %o', release_id);
53-
debug('release tag_name: %o', tag_name);
52+
debug('release release_id: %o', releaseId);
53+
debug('release tag_name: %o', tagName);
5454

5555
const {
5656
data: {html_url: url},
57-
} = await github.repos.updateRelease({...release, release_id, tag_name});
57+
} = await github.repos.updateRelease({...release, release_id: releaseId, tag_name: tagName});
5858

5959
logger.log('Updated GitHub release: %s', url);
6060

lib/get-fail-comment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const NEW_ISSUE_URL = `${HOME_URL}/issues/new`;
77
const formatError = error => `### ${error.message}
88
99
${error.details ||
10-
`Unfortunatly this error doesn't have any additionnal information.${
10+
`Unfortunately this error doesn't have any additional information.${
1111
error.pluginName
12-
? ` Feel free to kindly ask the author of the \`${error.pluginName}\` plugin to add more helpful informations.`
12+
? ` Feel free to kindly ask the author of the \`${error.pluginName}\` plugin to add more helpful information.`
1313
: ''
1414
}`}`;
1515

lib/publish.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {basename, extname, resolve} = require('path');
22
const {stat, readFile} = require('fs-extra');
3-
const {isPlainObject} = require('lodash');
3+
const {isPlainObject, template} = require('lodash');
44
const parseGithubUrl = require('parse-github-url');
55
const mime = require('mime');
66
const debug = require('debug')('semantic-release:github');
@@ -40,7 +40,7 @@ module.exports = async (pluginConfig, context) => {
4040
const draftRelease = {...release, draft: true};
4141

4242
const {
43-
data: {html_url: url, upload_url: uploadUrl, id: releaseId},
43+
data: {upload_url: uploadUrl, id: releaseId},
4444
} = await github.repos.createRelease(draftRelease);
4545

4646
// Append assets to the release
@@ -54,7 +54,7 @@ module.exports = async (pluginConfig, context) => {
5454

5555
try {
5656
file = await stat(resolve(cwd, filePath));
57-
} catch (error) {
57+
} catch (_) {
5858
logger.error('The asset %s cannot be read, and will be ignored.', filePath);
5959
return;
6060
}
@@ -64,7 +64,7 @@ module.exports = async (pluginConfig, context) => {
6464
return;
6565
}
6666

67-
const fileName = asset.name || basename(filePath);
67+
const fileName = template(asset.name || basename(filePath))(context);
6868
const upload = {
6969
url: uploadUrl,
7070
file: await readFile(resolve(cwd, filePath)),
@@ -79,7 +79,7 @@ module.exports = async (pluginConfig, context) => {
7979
debug('file name: %o', fileName);
8080

8181
if (isPlainObject(asset) && asset.label) {
82-
upload.label = asset.label;
82+
upload.label = template(asset.label)(context);
8383
}
8484

8585
const {
@@ -89,7 +89,9 @@ module.exports = async (pluginConfig, context) => {
8989
})
9090
);
9191

92-
await github.repos.updateRelease({owner, repo, release_id: releaseId, draft: false});
92+
const {
93+
data: {html_url: url},
94+
} = await github.repos.updateRelease({owner, repo, release_id: releaseId, draft: false});
9395

9496
logger.log('Published GitHub release: %s', url);
9597
return {url, name: RELEASE_NAME};

lib/success.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ module.exports = async (pluginConfig, context) => {
3030
} = resolveConfig(pluginConfig, context);
3131

3232
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
33-
let {name: repo, owner} = parseGithubUrl(repositoryUrl);
33+
const parsedUrl = parseGithubUrl(repositoryUrl);
3434
// In case the repo changed name, get the new `repo`/`owner` as the search API will not follow redirects
35-
[owner, repo] = (await github.repos.get({repo, owner})).data.full_name.split('/');
35+
const [owner, repo] = (await github.repos.get({repo: parsedUrl.name, owner: parsedUrl.owner})).data.full_name.split(
36+
'/'
37+
);
3638

3739
const errors = [];
3840

package.json

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
"bugs": {
1212
"url": "https://github.com/semantic-release/github/issues"
1313
},
14-
"config": {
15-
"commitizen": {
16-
"path": "cz-conventional-changelog"
17-
}
18-
},
1914
"contributors": [
2015
"Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
2116
"Gregor Martynus (https://twitter.com/gr2m)"
@@ -28,7 +23,7 @@
2823
"debug": "^4.0.0",
2924
"dir-glob": "^3.0.0",
3025
"fs-extra": "^8.0.0",
31-
"globby": "^9.0.0",
26+
"globby": "^10.0.0",
3227
"http-proxy-agent": "^2.1.0",
3328
"https-proxy-agent": "^2.2.1",
3429
"issue-parser": "^4.0.0",
@@ -41,19 +36,17 @@
4136
},
4237
"devDependencies": {
4338
"ava": "^2.0.0",
44-
"clear-module": "^3.0.0",
39+
"clear-module": "^4.0.0",
4540
"codecov": "^3.5.0",
46-
"commitizen": "^3.0.0",
47-
"cz-conventional-changelog": "^2.0.0",
48-
"nock": "^10.0.0",
41+
"nock": "^11.1.0",
4942
"nyc": "^14.1.1",
5043
"proxy": "^0.2.4",
5144
"proxyquire": "^2.0.0",
5245
"semantic-release": "^16.0.0-beta",
5346
"server-destroy": "^1.0.1",
5447
"sinon": "^7.1.1",
5548
"tempy": "^0.3.0",
56-
"xo": "^0.24.0"
49+
"xo": "^0.25.2"
5750
},
5851
"engines": {
5952
"node": ">=8.3"
@@ -103,7 +96,6 @@
10396
"url": "https://github.com/semantic-release/github.git"
10497
},
10598
"scripts": {
106-
"cm": "git-cz",
10799
"codecov": "codecov -f coverage/coverage-final.json",
108100
"lint": "xo",
109101
"pretest": "npm run lint",
@@ -117,12 +109,7 @@
117109
"camelcase": [
118110
"error",
119111
{
120-
"allow": [
121-
"issue_number",
122-
"pull_number",
123-
"tag_name",
124-
"release_id"
125-
]
112+
"properties": "never"
126113
}
127114
]
128115
}

test/get-fail-comment.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test('Comment with missing error details and pluginName', t => {
3434
t.regex(comment, /the `master` branch/);
3535
t.regex(
3636
comment,
37-
/---\n\n### Error message 1\n\nUnfortunatly this error doesn't have any additionnal information. Feel free to kindly ask the author of the `some-plugin` plugin to add more helpful informations.\n\n---/
37+
/---\n\n### Error message 1\n\nUnfortunately this error doesn't have any additional information. Feel free to kindly ask the author of the `some-plugin` plugin to add more helpful information.\n\n---/
3838
);
3939
});
4040

@@ -46,6 +46,6 @@ test('Comment with missing error details and no pluginName', t => {
4646
t.regex(comment, /the `master` branch/);
4747
t.regex(
4848
comment,
49-
/---\n\n### Error message 1\n\nUnfortunatly this error doesn't have any additionnal information.\n\n---/
49+
/---\n\n### Error message 1\n\nUnfortunately this error doesn't have any additional information.\n\n---/
5050
);
5151
});

test/get-success-comment.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Your **[semantic-release](${HOME_URL})** bot :package::rocket:`
2525
});
2626

2727
test('Comment for PR with multiple releases', t => {
28-
const issue = {number: 1, pull_request: {}}; // eslint-disable-line camelcase
28+
const issue = {number: 1, pull_request: {}};
2929
const releaseInfos = [
3030
{name: 'GitHub release', url: 'https://github.com/release'},
3131
{name: 'npm release', url: 'https://npm.com/release'},

0 commit comments

Comments
 (0)