Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ Options:
-b, --body text of release body
-o, --owner repo owner
-r, --repo repo name
-d, --draft publish as draft [default: false]
-p, --prerelease publish as prerelease [default: false]
-w, --workpath path to working directory [default: current directory]
-e, --endpoint GitHub API endpoint URL [default: "https://api.github.com"]
-a, --assets comma-delimited list of assets to upload [default: false]
--dry-run dry run (stops before release step) [default: false]
-y, --yes bypass confirmation prompt for release [default: false]
-d, --draft publish as draft [default: false]
-p, --prerelease publish as prerelease [default: false]
-w, --workpath path to working directory [default: current directory]
-e, --endpoint GitHub API endpoint URL [default: "https://api.github.com"]
--proxy Use a proxy with your environment variables [default: false]
-a, --assets comma-delimited list of assets to upload [default: false]
--dry-run dry run (stops before release step) [default: false]
-y, --yes bypass confirmation prompt for release [default: false]
-h, --help Show help
-v, --version Show version number
```
Expand All @@ -109,7 +110,8 @@ var options = {
prerelease: false,
repo: 'gh-release',
owner: 'ungoldman',
endpoint: 'https://api.github.com' // for GitHub enterprise, use http(s)://hostname/api/v3
endpoint: 'https://api.github.com', // for GitHub enterprise, use http(s)://hostname/api/v3
proxy: true // true will use environment variables, or string to specify a specific address
}

// options can also be just an empty object
Expand Down
1 change: 1 addition & 0 deletions bin/lib/get-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function getDefaults (workPath, isEnterprise, callback) {
dryRun: false,
yes: false,
endpoint: 'https://api.github.com',
proxy: false,
workpath: process.cwd(),
prerelease: false,
draft: false,
Expand Down
5 changes: 5 additions & 0 deletions bin/lib/yargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ module.exports = require('yargs')
default: 'https://api.github.com',
describe: 'GitHub API endpoint URL'
},
proxy: {
type: 'boolean',
default: false,
description: 'Use a proxy, uses your environment variables'
},
a: {
alias: 'assets',
type: 'string',
Expand Down
24 changes: 22 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const ghReleaseAssets = require('gh-release-assets')
const getDefaults = require('./bin/lib/get-defaults')
const Emitter = require('events').EventEmitter
const { Octokit } = require('@octokit/rest')
const { fetch: undiciFetch, EnvHttpProxyAgent } = require('undici')

const clientId = '04dac3c40b7e49b11f38'

Expand All @@ -24,6 +25,7 @@ const OPTIONS = {
yes: false,
draft: false,
endpoint: 'https://api.github.com',
proxy: false,
prerelease: false,
workpath: process.cwd()
},
Expand All @@ -39,6 +41,7 @@ const OPTIONS = {
'yes',
'draft',
'endpoint',
'proxy',
'prerelease',
'workpath',
'assets'
Expand Down Expand Up @@ -83,10 +86,27 @@ function _Release (options, emitter, callback) {
// err if auth info not provided (token or user/pass)
if (!getToken(options)) return callback(new Error('missing auth info'))

const octokit = new Octokit({
const octokitOptions = {
auth: getToken(options),
baseUrl: options.endpoint
})
}

if (options.proxy) {
const proxyFetch = (url, requestInit) => {
return undiciFetch(url, {
...requestInit,
dispatcher: new EnvHttpProxyAgent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10
})
})
}
octokitOptions.request = {
fetch: proxyFetch
}
}

const octokit = new Octokit(octokitOptions)

octokit.repos.getCommit({
owner: options.owner,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"Ted Janeczko <[email protected]>"
],
"dependencies": {
"@octokit/rest": "^20.1.2",
"@octokit/rest": "^22.0.0",
"changelog-parser": "^3.0.1",
"deep-extend": "^0.6.0",
"gauge": "^5.0.2",
Expand All @@ -30,6 +30,7 @@
"github-url-to-object": "^4.0.6",
"inquirer": "^8.2.6",
"shelljs": "^0.10.0",
"undici": "^7.15.0",
"update-notifier": "^5.1.0",
"yargs": "^17.7.2"
},
Expand Down