@acalcutt/node-pre-gyp-github 1.4.8 → 2.0.1-pre.0
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/LICENSE +22 -22
- package/README.md +67 -67
- package/bin/node-pre-gyp-github.js +25 -26
- package/index.js +149 -153
- package/package.json +52 -50
package/LICENSE
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Bill Christo
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Bill Christo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# node-pre-gyp-github
|
|
2
|
-
|
|
3
|
-
##### A node-pre-gyp module which provides the ability to publish to GitHub releases.
|
|
4
|
-
|
|
5
|
-
[](https://coveralls.io/github/bchr02/node-pre-gyp-github?branch=master)
|
|
6
|
-
[](https://gitter.im/bchr02/node-pre-gyp-github?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
|
|
10
|
-
Instead of ```node-pre-gyp publish``` use **```node-pre-gyp-github publish```**
|
|
11
|
-
|
|
12
|
-
## Options for publish command
|
|
13
|
-
|
|
14
|
-
* --silent : Turns verbose messages off.
|
|
15
|
-
* --release : Publish the GitHub Release immediately instead of creating a Draft.
|
|
16
|
-
|
|
17
|
-
For Ex. ```node-pre-gyp-github publish --release```
|
|
18
|
-
|
|
19
|
-
## Install
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install -g node-pre-gyp-github
|
|
23
|
-
# or
|
|
24
|
-
yarn global add node-pre-gyp-github
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Configuration
|
|
29
|
-
|
|
30
|
-
This module is intended to be used with node-pre-gyp. Therefore, be sure to configure and install node-pre-gyp first. After having done that, within **```package.json```** update the ```binary``` properties ```host``` and ```remote_path``` so it matches the following format:
|
|
31
|
-
|
|
32
|
-
```json
|
|
33
|
-
"host": "https://github.com/[owner]/[repo]/releases/download/",
|
|
34
|
-
"remote_path": "{version}"
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Be sure to replace ```[owner]```, ```[repo]```, with actual values,
|
|
38
|
-
but DO NOT replace ```{version}``` with actual version.
|
|
39
|
-
|
|
40
|
-
***WARNING: Variable substitutions are not supported on the ```host``` property and on the ```remote_path``` only ```{version}``` placeholder is supported. The value of ```remote_path``` after substitution will become a release tag name. Do not use [forbidden git tag characters](https://git-scm.com/docs/git-check-ref-format) for ```version``` and ```remote_path``` properties.***
|
|
41
|
-
|
|
42
|
-
Within GitHub, create a new authorization:
|
|
43
|
-
|
|
44
|
-
1. go to `Settings` -> `Developer settings`
|
|
45
|
-
2. click [`Personal access tokens`](https://github.com/settings/tokens)
|
|
46
|
-
3. click `Generate new token`
|
|
47
|
-
4. Select `public_repo` and `repo_deployment`
|
|
48
|
-
5. Generate Token
|
|
49
|
-
6. copy the key that's generated and set `NODE_PRE_GYP_GITHUB_TOKEN` environment variable to it. Within your command prompt:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
SET NODE_PRE_GYP_GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Example (Publish to GitHub as a Draft Release)
|
|
56
|
-
|
|
57
|
-
1. node-pre-gyp configure
|
|
58
|
-
2. node-pre-gyp build
|
|
59
|
-
3. node-pre-gyp package
|
|
60
|
-
4. node-pre-gyp-github publish
|
|
61
|
-
|
|
62
|
-
## Example (Publish to GitHub as a Release)
|
|
63
|
-
|
|
64
|
-
1. node-pre-gyp configure
|
|
65
|
-
2. node-pre-gyp build
|
|
66
|
-
3. node-pre-gyp package
|
|
67
|
-
4. node-pre-gyp-github publish --release
|
|
1
|
+
# node-pre-gyp-github
|
|
2
|
+
|
|
3
|
+
##### A node-pre-gyp module which provides the ability to publish to GitHub releases.
|
|
4
|
+
|
|
5
|
+
[](https://coveralls.io/github/bchr02/node-pre-gyp-github?branch=master)
|
|
6
|
+
[](https://gitter.im/bchr02/node-pre-gyp-github?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
Instead of ```node-pre-gyp publish``` use **```node-pre-gyp-github publish```**
|
|
11
|
+
|
|
12
|
+
## Options for publish command
|
|
13
|
+
|
|
14
|
+
* --silent : Turns verbose messages off.
|
|
15
|
+
* --release : Publish the GitHub Release immediately instead of creating a Draft.
|
|
16
|
+
|
|
17
|
+
For Ex. ```node-pre-gyp-github publish --release```
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g node-pre-gyp-github
|
|
23
|
+
# or
|
|
24
|
+
yarn global add node-pre-gyp-github
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
This module is intended to be used with node-pre-gyp. Therefore, be sure to configure and install node-pre-gyp first. After having done that, within **```package.json```** update the ```binary``` properties ```host``` and ```remote_path``` so it matches the following format:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
"host": "https://github.com/[owner]/[repo]/releases/download/",
|
|
34
|
+
"remote_path": "{version}"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Be sure to replace ```[owner]```, ```[repo]```, with actual values,
|
|
38
|
+
but DO NOT replace ```{version}``` with actual version.
|
|
39
|
+
|
|
40
|
+
***WARNING: Variable substitutions are not supported on the ```host``` property and on the ```remote_path``` only ```{version}``` placeholder is supported. The value of ```remote_path``` after substitution will become a release tag name. Do not use [forbidden git tag characters](https://git-scm.com/docs/git-check-ref-format) for ```version``` and ```remote_path``` properties.***
|
|
41
|
+
|
|
42
|
+
Within GitHub, create a new authorization:
|
|
43
|
+
|
|
44
|
+
1. go to `Settings` -> `Developer settings`
|
|
45
|
+
2. click [`Personal access tokens`](https://github.com/settings/tokens)
|
|
46
|
+
3. click `Generate new token`
|
|
47
|
+
4. Select `public_repo` and `repo_deployment`
|
|
48
|
+
5. Generate Token
|
|
49
|
+
6. copy the key that's generated and set `NODE_PRE_GYP_GITHUB_TOKEN` environment variable to it. Within your command prompt:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
SET NODE_PRE_GYP_GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Example (Publish to GitHub as a Draft Release)
|
|
56
|
+
|
|
57
|
+
1. node-pre-gyp configure
|
|
58
|
+
2. node-pre-gyp build
|
|
59
|
+
3. node-pre-gyp package
|
|
60
|
+
4. node-pre-gyp-github publish
|
|
61
|
+
|
|
62
|
+
## Example (Publish to GitHub as a Release)
|
|
63
|
+
|
|
64
|
+
1. node-pre-gyp configure
|
|
65
|
+
2. node-pre-gyp build
|
|
66
|
+
3. node-pre-gyp package
|
|
67
|
+
4. node-pre-gyp-github publish --release
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const NodePreGypGithub = require('../index.js');
|
|
4
|
-
const program = require(
|
|
5
|
-
|
|
6
|
-
program
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
program.parseAsync(process.argv);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const NodePreGypGithub = require('../index.js');
|
|
4
|
+
const { program } = require("commander");
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.command("publish")
|
|
8
|
+
.description("publishes the contents of ./build/stage/{version} to the current version's GitHub release")
|
|
9
|
+
.option("-r, --release", "publish immediately, do not create draft")
|
|
10
|
+
.option("-s, --silent", "turns verbose messages off")
|
|
11
|
+
.action(async (options) => {
|
|
12
|
+
const opts = {
|
|
13
|
+
draft: !options.release,
|
|
14
|
+
verbose: !options.silent,
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
const nodePreGypGithub = new NodePreGypGithub();
|
|
18
|
+
await nodePreGypGithub.publish(opts);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.error(`An error occurred whilst publishing:`, err);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
program.parseAsync(process.argv);
|
package/index.js
CHANGED
|
@@ -1,153 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const cwd = process.cwd();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
await this.uploadAssets();
|
|
152
|
-
}
|
|
153
|
-
};
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { Octokit } from '@octokit/rest';
|
|
4
|
+
|
|
5
|
+
const cwd = process.cwd();
|
|
6
|
+
|
|
7
|
+
let verbose;
|
|
8
|
+
|
|
9
|
+
function consoleLog(x) {
|
|
10
|
+
return (verbose) ? console.log(x) : false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class NodePreGypGithub {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.stage_dir = path.join(cwd, 'build', 'stage');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
init() {
|
|
19
|
+
const token = process.env.NODE_PRE_GYP_GITHUB_TOKEN;
|
|
20
|
+
if (!token) {
|
|
21
|
+
throw new Error('NODE_PRE_GYP_GITHUB_TOKEN environment variable not found');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.package_json = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
|
|
25
|
+
|
|
26
|
+
if (!this.package_json.repository || !this.package_json.repository.url) {
|
|
27
|
+
throw new Error('Missing repository.url in package.json');
|
|
28
|
+
} else {
|
|
29
|
+
const ownerRepo = this.package_json.repository.url.match(/https?:\/\/([^\/]+)\/(.*)(?=\.git)/i);
|
|
30
|
+
if (!ownerRepo) {
|
|
31
|
+
throw new Error('A correctly formatted GitHub repository.url was not found within package.json');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.host = 'api.' + ownerRepo[1];
|
|
35
|
+
const [owner, repo] = ownerRepo[2].split('/');
|
|
36
|
+
this.owner = owner;
|
|
37
|
+
this.repo = repo;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const hostPrefix = 'https://' + this.host + '/' + this.owner + '/' + this.repo + '/releases/download/';
|
|
41
|
+
if (!this.package_json.binary || typeof this.package_json.binary !== 'object' || typeof this.package_json.binary.host !== 'string') {
|
|
42
|
+
throw new Error('Missing binary.host in package.json');
|
|
43
|
+
}
|
|
44
|
+
else if (this.package_json.binary.host.replace('https://', 'https://api.').substring(0, hostPrefix.length) !== hostPrefix) {
|
|
45
|
+
throw new Error('binary.host in package.json should begin with: "' + hostPrefix + '"');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.octokit = this.createOctokitInstance(token);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
createOctokitInstance(token) {
|
|
52
|
+
return new Octokit({
|
|
53
|
+
baseUrl: "https://" + this.host,
|
|
54
|
+
auth: token,
|
|
55
|
+
userAgent: this.package_json.name ? this.package_json.name : "node-pre-gyp-github",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async createRelease(args) {
|
|
60
|
+
const prerelease = this.package_json.version.includes('pre');
|
|
61
|
+
|
|
62
|
+
const options = {
|
|
63
|
+
host: this.host,
|
|
64
|
+
owner: this.owner,
|
|
65
|
+
repo: this.repo,
|
|
66
|
+
tag_name: this.package_json.version,
|
|
67
|
+
target_commitish: 'main',
|
|
68
|
+
name: 'node-v' + this.package_json.version,
|
|
69
|
+
body: this.package_json.name + ' ' + this.package_json.version,
|
|
70
|
+
draft: true,
|
|
71
|
+
prerelease: prerelease
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Object.keys(args).forEach(function (key) {
|
|
75
|
+
if (args.hasOwnProperty(key) && options.hasOwnProperty(key)) {
|
|
76
|
+
options[key] = args[key];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const release = await this.octokit.rest.repos.createRelease(options);
|
|
81
|
+
return release;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async uploadAssets() {
|
|
85
|
+
consoleLog("Stage directory path: " + path.join(this.stage_dir));
|
|
86
|
+
|
|
87
|
+
const files = fs.readdirSync(path.join(this.stage_dir));
|
|
88
|
+
if (!files.length) throw new Error('No files found within the stage directory: ' + this.stage_dir);
|
|
89
|
+
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
if (this.release && this.release.assets) {
|
|
92
|
+
const asset = this.release.assets.filter(element => element.name === file);
|
|
93
|
+
if (asset.length) {
|
|
94
|
+
throw new Error("Staged file " + file + " found but it already exists in release " + this.release.tag_name + ". If you would like to replace it, you must first manually delete it within GitHub.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
consoleLog(`Staged file ${file} found - proceeding to upload`);
|
|
99
|
+
|
|
100
|
+
const filePath = path.join(this.stage_dir, file);
|
|
101
|
+
const fileContents = fs.readFileSync(filePath);
|
|
102
|
+
|
|
103
|
+
await this.octokit.rest.repos.uploadReleaseAsset({
|
|
104
|
+
owner: this.owner,
|
|
105
|
+
repo: this.repo,
|
|
106
|
+
release_id: this.release.id,
|
|
107
|
+
name: file,
|
|
108
|
+
data: fileContents
|
|
109
|
+
});
|
|
110
|
+
consoleLog('Staged file ' + file + ' saved to ' + this.owner + '/' + this.repo + ' release ' + this.release.tag_name + ' successfully.');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async publish(options = {}) {
|
|
115
|
+
verbose = (typeof options.verbose === 'undefined' || options.verbose) ? true : false;
|
|
116
|
+
|
|
117
|
+
await this.init();
|
|
118
|
+
|
|
119
|
+
const { data } = await this.octokit.rest.repos.listReleases({
|
|
120
|
+
owner: this.owner,
|
|
121
|
+
repo: this.repo
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// when remote_path is set expect files to be in stage_dir / remote_path after substitution
|
|
125
|
+
if (this.package_json.binary.remote_path) {
|
|
126
|
+
options.tag_name = this.package_json.binary.remote_path.replace(/\{version\}/g, this.package_json.version);
|
|
127
|
+
this.stage_dir = path.join(this.stage_dir, options.tag_name);
|
|
128
|
+
} else {
|
|
129
|
+
// This is here for backwards compatibility for before binary.remote_path support was added in version 1.2.0.
|
|
130
|
+
options.tag_name = this.package_json.version;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const release = data.filter(element => element.tag_name === options.tag_name);
|
|
134
|
+
|
|
135
|
+
if (release.length === 0) {
|
|
136
|
+
const release = await this.createRelease(options);
|
|
137
|
+
this.release = release.data;
|
|
138
|
+
if (this.release.draft) {
|
|
139
|
+
consoleLog(`Release ${this.release.tag_name} not found, so a draft release was created. YOU MUST MANUALLY PUBLISH THIS DRAFT WITHIN GITHUB FOR IT TO BE ACCESSIBLE.`);
|
|
140
|
+
} else {
|
|
141
|
+
consoleLog(`Release ${this.release.tag_name} not found, so a new release was created and published.`);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
this.release = release[0];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
await this.uploadAssets();
|
|
148
|
+
}
|
|
149
|
+
}
|
package/package.json
CHANGED
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@acalcutt/node-pre-gyp-github",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A node-pre-gyp module which provides the ability to publish to GitHub releases.",
|
|
5
|
-
"bin": "./bin/node-pre-gyp-github.js",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"c",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@acalcutt/node-pre-gyp-github",
|
|
3
|
+
"version": "2.0.1-pre.0",
|
|
4
|
+
"description": "A node-pre-gyp module which provides the ability to publish to GitHub releases.",
|
|
5
|
+
"bin": "./bin/node-pre-gyp-github.js",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "c8 --reporter=lcov --reporter=text mocha",
|
|
10
|
+
"coverage": "c8 --reporter=text-lcov mocha | coveralls",
|
|
11
|
+
"ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then npm publish && git push --follow-tags; fi"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/acalcutt/node-pre-gyp-github.git"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"index.js"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"node-pre-gyp",
|
|
23
|
+
"binary",
|
|
24
|
+
"bindings",
|
|
25
|
+
"c++",
|
|
26
|
+
"c",
|
|
27
|
+
"native",
|
|
28
|
+
"addon",
|
|
29
|
+
"module",
|
|
30
|
+
"github",
|
|
31
|
+
"releases"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@octokit/rest": "21.1.1",
|
|
35
|
+
"commander": "13.1.0",
|
|
36
|
+
"semver": "^7.6.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"c8": "^10.1.3",
|
|
40
|
+
"chai": "5.2.0",
|
|
41
|
+
"chai-as-promised": "8.0.1",
|
|
42
|
+
"coveralls-next": "^4.2.1",
|
|
43
|
+
"mocha": "11.1.0",
|
|
44
|
+
"sinon": "20.0.0"
|
|
45
|
+
},
|
|
46
|
+
"author": "Bill Christo",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/acalcutt/node-pre-gyp-github/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/acalcutt/node-pre-gyp-github#readme"
|
|
52
|
+
}
|