@semantic-release/github 2.2.3 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @semantic-release/github
2
2
 
3
- Set of [semantic-release](https://github.com/semantic-release/semantic-release) plugins for publishing a [Github release](https://help.github.com/articles/about-releases).
3
+ Set of [Semantic-release](https://github.com/semantic-release/semantic-release) plugins for publishing a
4
+ [GitHub release](https://help.github.com/articles/about-releases).
4
5
 
5
6
  [![Travis](https://img.shields.io/travis/semantic-release/github.svg)](https://travis-ci.org/semantic-release/github)
6
7
  [![Codecov](https://img.shields.io/codecov/c/github/semantic-release/github.svg)](https://codecov.io/gh/semantic-release/github)
@@ -8,24 +9,26 @@ Set of [semantic-release](https://github.com/semantic-release/semantic-release)
8
9
 
9
10
  ## verifyConditions
10
11
 
11
- Verify the presence and the validity of the `githubToken` (set via option or environment variable) and the `assets` option configuration.
12
+ Verify the presence and the validity of the authentication (set via [environment variables](#environment-variables)) and
13
+ the [assets](#assets) option configuration.
12
14
 
13
15
  ## publish
14
16
 
15
- Publish a [Github release](https://help.github.com/articles/about-releases), optionnaly uploading files.
17
+ Publish a [GitHub release](https://help.github.com/articles/about-releases), optionally uploading files.
16
18
 
17
19
  ## Configuration
18
20
 
19
- ### Github Repository authentication
21
+ ### GitHub authentication
20
22
 
21
- The `Github` authentication configuration is **required** and can be set via [environment variables](#environment-variables).
23
+ The GitHub authentication configuration is **required** and can be set via
24
+ [environment variables](#environment-variables).
22
25
 
23
- Only the [personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) authentication is supported.
26
+ Follow the [Creating a personal access token for the command line](https://help.github.com/articles/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.
24
27
 
25
28
  ### Environment variables
26
29
 
27
30
  | Variable | Description |
28
- | ------------------------------ | ----------------------------------------------------------|
31
+ | ------------------------------ | --------------------------------------------------------- |
29
32
  | `GH_TOKEN` or `GITHUB_TOKEN` | **Required.** The token used to authenticate with GitHub. |
30
33
  | `GH_URL` or `GITHUB_URL` | The GitHub Enterprise endpoint. |
31
34
  | `GH_PREFIX` or `GITHUB_PREFIX` | The GitHub Enterprise API prefix. |
@@ -34,40 +37,48 @@ Only the [personal token](https://help.github.com/articles/creating-a-personal-a
34
37
 
35
38
  | Option | Description | Default |
36
39
  | --------------------- | ------------------------------------------------------------------ | ---------------------------------------------------- |
37
- | `githubToken` | **Required.** The token used to authenticate with GitHub. | `GH_TOKEN` or `GITHUB_TOKEN` environment variable. |
38
40
  | `githubUrl` | The GitHub Enterprise endpoint. | `GH_URL` or `GITHUB_URL` environment variable. |
39
41
  | `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. |
40
42
  | `assets` | An array of files to upload to the release. See [assets](#assets). | - |
41
43
 
42
44
  #### `assets`
43
45
 
44
- 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
46
+ Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array` of
47
+ [globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties
45
48
 
46
49
  | Property | Description | Default |
47
50
  | -------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------ |
48
51
  | `path` | **Required.** A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. | - |
49
- | `name` | The name of the downloadable file on the Github release. | File name extracted from the `path`. |
50
- | `label` | Short description of the file displayed on the Github release. | - |
52
+ | `name` | The name of the downloadable file on the GitHub release. | File name extracted from the `path`. |
53
+ | `label` | Short description of the file displayed on the GitHub release. | - |
51
54
 
52
- Each entry in the `assets` `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"]`).
55
+ Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
56
+ can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together
57
+ (`["dist/**", "!**/*.css"]`).
53
58
 
54
59
  If a directory is configured, all the files under this directory and its children will be included.
55
60
 
56
- Files can be included enven if they have a match in `.gitignore`.
61
+ Files can be included even if they have a match in `.gitignore`.
57
62
 
58
63
  ##### `assets` examples
59
64
 
60
65
  `'dist/*.js'`: include all the `js` files in the `dist` directory, but not in its sub-directories.
61
66
 
62
- `[['dist', '!**/*.css']]`: include all the files in the `dist` directory and its sub-directories excluding the `css` files.
67
+ `[['dist', '!**/*.css']]`: include all the files in the `dist` directory and its sub-directories excluding the `css`
68
+ files.
63
69
 
64
- `[{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.
70
+ `[{path: 'dist/MyLibrary.js', label: 'MyLibrary JS distribution'}, {path: 'dist/MyLibrary.css', label: 'MyLibrary CSS
71
+ distribution'}]`: include the `dist/MyLibrary.js` and `dist/MyLibrary.css` files, and label them `MyLibrary JS
72
+ distribution` and `MyLibrary CSS distribution` in the GitHub release.
65
73
 
66
- `[['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.
74
+ `[['dist/**/*.{js,css}', '!**/*.min.*'], {path: 'build/MyLibrary.zip', label: 'MyLibrary'}]`: include all the `js` and
75
+ `css` files in the `dist` directory and its sub-directories excluding the minified version, plus the
76
+ `build/MyLibrary.zip` file and label it `MyLibrary` in the GitHub release.
67
77
 
68
78
  ### Usage
69
79
 
70
- The plugins are used by default by [semantic-release](https://github.com/semantic-release/semantic-release) so no specific configuration is requiered if `githubToken`, `githubUrl` and `githubApiPathPrefix` are set via environment variable.
80
+ The plugins are used by default by [Semantic-release](https://github.com/semantic-release/semantic-release) so no
81
+ specific configuration is required if `githubUrl` and `githubApiPathPrefix` are set via environment variable.
71
82
 
72
83
  Each individual plugin can be disabled, replaced or used with other plugins in the `package.json`:
73
84
 
@@ -81,7 +92,7 @@ Each individual plugin can be disabled, replaced or used with other plugins in t
81
92
  }
82
93
  ```
83
94
 
84
- Options can be set within the plugin definition in the `semantic-release` configuration file:
95
+ Options can be set within the plugin definition in the Semantic-release configuration file:
85
96
 
86
97
  ```json
87
98
  {
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
- const verifyGithub = require('./lib/verify');
2
- const publishGithub = require('./lib/publish');
1
+ const verifyGitHub = require('./lib/verify');
2
+ const publishGitHub = require('./lib/publish');
3
3
 
4
4
  let verified;
5
5
 
6
6
  async function verifyConditions(pluginConfig, {options, logger}) {
7
- // If the Github publish plugin is used and has `assets` configured, validate it now in order to prevent any release if the configuration is wrong
7
+ // If the GitHub publish plugin is used and has `assets` configured, validate it now in order to prevent any release if the configuration is wrong
8
8
  if (options.publish) {
9
9
  const publishPlugin = (Array.isArray(options.publish) ? options.publish : [options.publish]).find(
10
10
  config => config.path && config.path === '@semantic-release/github'
@@ -14,16 +14,16 @@ async function verifyConditions(pluginConfig, {options, logger}) {
14
14
  }
15
15
  }
16
16
 
17
- await verifyGithub(pluginConfig, options, logger);
17
+ await verifyGitHub(pluginConfig, options, logger);
18
18
  verified = true;
19
19
  }
20
20
 
21
21
  async function publish(pluginConfig, {nextRelease, options, logger}) {
22
22
  if (!verified) {
23
- await verifyGithub(pluginConfig, options, logger);
23
+ await verifyGitHub(pluginConfig, options, logger);
24
24
  verified = true;
25
25
  }
26
- await publishGithub(pluginConfig, options, nextRelease, logger);
26
+ await publishGitHub(pluginConfig, options, nextRelease, logger);
27
27
  }
28
28
 
29
29
  module.exports = {verifyConditions, publish};
package/lib/get-client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const url = require('url');
2
- const GitHubApi = require('github');
2
+ const GitHubApi = require('@octokit/rest');
3
3
 
4
4
  module.exports = (githubToken, githubUrl, githubApiPathPrefix) => {
5
5
  const {port, protocol, hostname} = githubUrl ? url.parse(githubUrl) : {};
package/lib/publish.js CHANGED
@@ -36,7 +36,7 @@ module.exports = async (pluginConfig, {branch, repositoryUrl}, {version, gitHead
36
36
  }
37
37
 
38
38
  const {data: {html_url: htmlUrl, upload_url: uploadUrl}} = await github.repos.createRelease(release);
39
- logger.log('Published Github release: %s', htmlUrl);
39
+ logger.log('Published GitHub release: %s', htmlUrl);
40
40
 
41
41
  if (assets && assets.length > 0) {
42
42
  const globbedAssets = await globAssets(assets);
@@ -1,7 +1,7 @@
1
1
  const {castArray} = require('lodash');
2
2
 
3
- module.exports = ({githubToken, githubUrl, githubApiPathPrefix, assets}) => ({
4
- githubToken: githubToken || process.env.GH_TOKEN || process.env.GITHUB_TOKEN,
3
+ module.exports = ({githubUrl, githubApiPathPrefix, assets}) => ({
4
+ githubToken: process.env.GH_TOKEN || process.env.GITHUB_TOKEN,
5
5
  githubUrl: githubUrl || process.env.GH_URL || process.env.GITHUB_URL,
6
6
  githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX,
7
7
  assets: assets ? castArray(assets) : assets,
package/lib/verify.js CHANGED
@@ -29,15 +29,15 @@ module.exports = async (pluginConfig, {repositoryUrl}, logger) => {
29
29
  const {name: repo, owner} = parseGithubUrl(repositoryUrl);
30
30
  if (!owner || !repo) {
31
31
  throw new SemanticReleaseError(
32
- `The git repository URL ${repositoryUrl} is not a valid Github URL.`,
32
+ `The git repository URL ${repositoryUrl} is not a valid GitHub URL.`,
33
33
  'EINVALIDGITURL'
34
34
  );
35
35
  }
36
36
 
37
37
  if (githubUrl) {
38
- logger.log('Verify Github authentication (%s)', urlJoin(githubUrl, githubApiPathPrefix));
38
+ logger.log('Verify GitHub authentication (%s)', urlJoin(githubUrl, githubApiPathPrefix));
39
39
  } else {
40
- logger.log('Verify Github authentication');
40
+ logger.log('Verify GitHub authentication');
41
41
  }
42
42
 
43
43
  const github = getClient(githubToken, githubUrl, githubApiPathPrefix);
@@ -47,7 +47,7 @@ module.exports = async (pluginConfig, {repositoryUrl}, logger) => {
47
47
  ({data: {permissions: {push}}} = await github.repos.get({repo, owner}));
48
48
  } catch (err) {
49
49
  if (err.code === 401) {
50
- throw new SemanticReleaseError('Invalid Github token.', 'EINVALIDGHTOKEN');
50
+ throw new SemanticReleaseError('Invalid GitHub token.', 'EINVALIDGHTOKEN');
51
51
  } else if (err.code === 404) {
52
52
  throw new SemanticReleaseError(`The repository ${owner}/${repo} doesn't exist.`, 'EMISSINGREPO');
53
53
  }
package/package.json CHANGED
@@ -1 +1,108 @@
1
- {"name":"@semantic-release/github","description":"Set of semantic-release plugins for publishing a Github release","version":"2.2.3","author":"Pierre Vanduynslager (https://twitter.com/@pvdlg_)","bugs":{"url":"https://github.com/semantic-release/github/issues"},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"contributors":["Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)","Gregor Martynus (https://twitter.com/gr2m)"],"dependencies":{"@semantic-release/error":"^2.1.0","debug":"^3.1.0","fs-extra":"^5.0.0","github":"^13.0.0","globby":"^7.1.1","lodash":"^4.17.4","mime":"^2.0.3","p-reduce":"^1.0.0","parse-github-url":"^1.0.1","url-join":"^2.0.2"},"devDependencies":{"ava":"^0.24.0","clear-module":"^2.1.0","codecov":"^3.0.0","commitizen":"^2.9.6","cz-conventional-changelog":"^2.0.0","eslint-config-prettier":"^2.8.0","eslint-plugin-prettier":"^2.3.0","nock":"^9.1.0","nyc":"^11.2.1","prettier":"~1.9.2","semantic-release":"^10.0.0","sinon":"^4.0.0","tempy":"^0.2.1","xo":"^0.18.2"},"engines":{"node":">=4"},"files":["lib","index.js"],"homepage":"https://github.com/semantic-release/github#readme","keywords":["git","github","publish","release","semantic-release","version"],"license":"MIT","main":"index.js","nyc":{"include":["lib/**/*.js","index.js"],"reporter":["json","text","html"],"all":true},"prettier":{"printWidth":120,"singleQuote":true,"bracketSpacing":false,"trailingComma":"es5"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"https://github.com/semantic-release/github.git"},"scripts":{"cm":"git-cz","codecov":"codecov -f coverage/coverage-final.json","lint":"xo","pretest":"npm run lint","semantic-release":"semantic-release","test":"nyc ava -v"},"xo":{"extends":["prettier"],"plugins":["prettier"],"rules":{"prettier/prettier":2}}}
1
+ {
2
+ "name": "@semantic-release/github",
3
+ "description": "Set of semantic-release plugins for publishing a GitHub release",
4
+ "version": "3.0.3",
5
+ "author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
6
+ "bugs": {
7
+ "url": "https://github.com/semantic-release/github/issues"
8
+ },
9
+ "config": {
10
+ "commitizen": {
11
+ "path": "cz-conventional-changelog"
12
+ }
13
+ },
14
+ "contributors": [
15
+ "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
16
+ "Gregor Martynus (https://twitter.com/gr2m)"
17
+ ],
18
+ "dependencies": {
19
+ "@octokit/rest": "^14.0.3",
20
+ "@semantic-release/error": "^2.1.0",
21
+ "debug": "^3.1.0",
22
+ "fs-extra": "^5.0.0",
23
+ "globby": "^7.1.1",
24
+ "lodash": "^4.17.4",
25
+ "mime": "^2.0.3",
26
+ "p-reduce": "^1.0.0",
27
+ "parse-github-url": "^1.0.1",
28
+ "url-join": "^3.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "ava": "^0.24.0",
32
+ "clear-module": "^2.1.0",
33
+ "codecov": "^3.0.0",
34
+ "commitizen": "^2.9.6",
35
+ "cz-conventional-changelog": "^2.0.0",
36
+ "eslint-config-prettier": "^2.8.0",
37
+ "eslint-plugin-prettier": "^2.3.0",
38
+ "nock": "^9.1.0",
39
+ "nyc": "^11.2.1",
40
+ "prettier": "~1.10.0",
41
+ "semantic-release": "^12.2.2",
42
+ "sinon": "^4.0.0",
43
+ "tempy": "^0.2.1",
44
+ "xo": "^0.18.2"
45
+ },
46
+ "engines": {
47
+ "node": ">=4"
48
+ },
49
+ "files": [
50
+ "lib",
51
+ "index.js"
52
+ ],
53
+ "homepage": "https://github.com/semantic-release/github#readme",
54
+ "keywords": [
55
+ "git",
56
+ "github",
57
+ "publish",
58
+ "release",
59
+ "semantic-release",
60
+ "version"
61
+ ],
62
+ "license": "MIT",
63
+ "main": "index.js",
64
+ "nyc": {
65
+ "include": [
66
+ "lib/**/*.js",
67
+ "index.js"
68
+ ],
69
+ "reporter": [
70
+ "json",
71
+ "text",
72
+ "html"
73
+ ],
74
+ "all": true
75
+ },
76
+ "prettier": {
77
+ "printWidth": 120,
78
+ "singleQuote": true,
79
+ "bracketSpacing": false,
80
+ "trailingComma": "es5"
81
+ },
82
+ "publishConfig": {
83
+ "access": "public"
84
+ },
85
+ "repository": {
86
+ "type": "git",
87
+ "url": "https://github.com/semantic-release/github.git"
88
+ },
89
+ "scripts": {
90
+ "cm": "git-cz",
91
+ "codecov": "codecov -f coverage/coverage-final.json",
92
+ "lint": "xo",
93
+ "pretest": "npm run lint",
94
+ "semantic-release": "semantic-release",
95
+ "test": "nyc ava -v"
96
+ },
97
+ "xo": {
98
+ "extends": [
99
+ "prettier"
100
+ ],
101
+ "plugins": [
102
+ "prettier"
103
+ ],
104
+ "rules": {
105
+ "prettier/prettier": 2
106
+ }
107
+ }
108
+ }