UNPKG

778 BJavaScriptView Raw
1import request from 'request-promise-native';
2import { GITHUB_API_REPOS_URL } from "./utils";
3export const makeWorkspacesGithubReleases = async (logs, prefixes, options) => {
4 if (typeof options.token !== 'string') {
5 throw new Error('GitHub token is required');
6 }
7
8 for (const log of logs) {
9 await request({
10 uri: `${GITHUB_API_REPOS_URL}${options.username}/${options.repo}/releases`,
11 method: 'POST',
12 headers: {
13 Authorization: `token ${options.token}`,
14 'User-Agent': 'auto-tools'
15 },
16 json: {
17 tag_name: `${log.name}@${log.version}`,
18 name: `${log.name}@${log.version}`,
19 body: log.messages.map(message => `* ${prefixes.required[message.type].value} ${message.value}`).join('\n')
20 }
21 });
22 }
23};
\No newline at end of file