@signalk/github-create-release
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -36,38 +36,44 @@ #!/usr/bin/env node | ||
async function main() { | ||
const tags = await octokit.repos.listTags({owner, repo, per_page:!updateAll ? 2 : 100, pages:1 }) | ||
for ( let i = 0; i < tags.data.length; i++ ) { | ||
const tag = tags.data[i] | ||
if ( tag.name != 'latest' && i != 0 ) { | ||
const prev = tags.data[i-1].name | ||
const commits = await octokit.repos.compareCommits({owner, repo, base:tag.name, head:prev}) | ||
try | ||
{ | ||
const tags = await octokit.repos.listTags({owner, repo, per_page:!updateAll ? 2 : 100, pages:1 }) | ||
const donePRs = [] | ||
let body = '' | ||
for ( let j = 0; j < commits.data.commits.length; j++ ) { | ||
const commit = commits.data.commits[j] | ||
const prs = await octokit.search.issuesAndPullRequests({ q: `type:pr repo:${owner}/${repo} ${commit.sha}` }) | ||
if ( prs.data.items.length > 0 ) { | ||
const pr = prs.data.items[0] | ||
if ( donePRs.indexOf(pr.number) == -1 ) { | ||
donePRs.push(pr.number) | ||
body += `+ [#${pr.number}](${pr.pull_request.url}) ${pr.title} (@${pr.user.login})\n` | ||
for ( let i = 0; i < tags.data.length; i++ ) { | ||
const tag = tags.data[i] | ||
if ( tag.name != 'latest' && i != 0 ) { | ||
const prev = tags.data[i-1].name | ||
const commits = await octokit.repos.compareCommits({owner, repo, base:tag.name, head:prev}) | ||
const donePRs = [] | ||
let body = '' | ||
for ( let j = 0; j < commits.data.commits.length; j++ ) { | ||
const commit = commits.data.commits[j] | ||
const prs = await octokit.search.issuesAndPullRequests({ q: `type:pr repo:${owner}/${repo} ${commit.sha}` }) | ||
if ( prs.data.items.length > 0 ) { | ||
const pr = prs.data.items[0] | ||
if ( donePRs.indexOf(pr.number) == -1 ) { | ||
donePRs.push(pr.number) | ||
body += `+ [#${pr.number}](${pr.pull_request.url}) ${pr.title} (@${pr.user.login})\n` | ||
} | ||
} | ||
} | ||
} | ||
const baseUrl = npmBaseUrl ? npmBaseUrl : `https://www.npmjs.com/package/@${owner}/${repo}` | ||
body += `\n\n[This version in npm](${baseUrl}/v/${prev.slice(1)})` | ||
try { | ||
await octokit.repos.createRelease({owner, repo, tag_name: prev, body:body}) | ||
} catch ( e ) { | ||
const release = await octokit.repos.getReleaseByTag({owner, repo, tag:prev}) | ||
await octokit.repos.updateRelease({owner, repo, release_id: release.data.id, prev, body:body}) | ||
const baseUrl = npmBaseUrl ? npmBaseUrl : `https://www.npmjs.com/package/@${owner}/${repo}` | ||
body += `\n\n[This version in npm](${baseUrl}/v/${prev.slice(1)})` | ||
try { | ||
await octokit.repos.createRelease({owner, repo, tag_name: prev, body:body}) | ||
} catch ( e ) { | ||
const release = await octokit.repos.getReleaseByTag({owner, repo, tag:prev}) | ||
await octokit.repos.updateRelease({owner, repo, release_id: release.data.id, prev, body:body}) | ||
} | ||
console.log(`created or updated ${prev}`) | ||
if ( !updateAll ) { | ||
break | ||
} | ||
} | ||
console.log(`created or updated ${prev}`) | ||
if ( !updateAll ) { | ||
break | ||
} | ||
} | ||
} catch ( e ) { | ||
console.error(e) | ||
process.exit(1) | ||
} | ||
@@ -74,0 +80,0 @@ } |
{ | ||
"name": "@signalk/github-create-release", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Create a GitHub Release Using Pull Requests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14990
68