-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for draft and prerelease #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getReleases api will return only 30 results (max 100) per page. You have to iterate all pages to fetch all results.
You can refer to below code to fetch all results. (async () => {
const { owner, repo, tag, name, body } = program;
try {
let page = 1;
let lastPage = 1;
do {
const releases = await getReleases({
owner: owner,
repo: repo,
page: page,
per_page: 30
});
console.log(`Fetched ${releases.length} results at page ${page}.`);
const pagination = (releases.meta.link || '').split(',')
.reduce((acc, link) => {
const r = link.match(/\?page=(\d)+.*rel="(\w+)"/);
if (r && r[1] && r[2]) {
const key = r[2];
const value = Number(r[1]) || 0;
acc[key] = value;
}
return acc;
}, {});
if (pagination.last > 0) {
lastPage = pagination.last;
}
++page;
} while (page <= lastPage);
} catch (err) {
// Ignore error
}
})(); |
Thanks for the code. I added it in. |
It looks great. Thank you for your contribution. |
Great. Any chance of a release anytime soon so I can use it? :) |
Published v0.4.0 |
I need to create all of my GH releases from CI as drafts. Draft and prerelease options we missing. This PR adds them.
Additionally, draft releases are not returned by the
getReleaseByTag
API so I ported the function over to usegetReleases
with a filter instead.