Ability to update existing release body (#36)
* Ability to update existing release body * Updated lib, fixed typo in workflow error message
This commit is contained in:
parent
7a7960d4c7
commit
62eba970e0
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -21,6 +21,6 @@ jobs:
|
|||||||
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
|
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
|
||||||
run: |
|
run: |
|
||||||
git diff --exit-code --stat -- . ':!node_modules' \
|
git diff --exit-code --stat -- . ':!node_modules' \
|
||||||
|| (echo "##[error] found changed files after build. please 'npm run build && npm run format'" \
|
|| (echo "##[error] found changed files after build. please 'npm run build && npm run fmt'" \
|
||||||
"and check in all changes" \
|
"and check in all changes" \
|
||||||
&& exit 1)
|
&& exit 1)
|
@ -30,6 +30,9 @@ class GitHubReleaser {
|
|||||||
createRelease(params) {
|
createRelease(params) {
|
||||||
return this.github.repos.createRelease(params);
|
return this.github.repos.createRelease(params);
|
||||||
}
|
}
|
||||||
|
updateRelease(params) {
|
||||||
|
return this.github.repos.updateRelease(params);
|
||||||
|
}
|
||||||
allReleases(params) {
|
allReleases(params) {
|
||||||
const updatedParams = Object.assign({ per_page: 100 }, params);
|
const updatedParams = Object.assign({ per_page: 100 }, params);
|
||||||
return this.github.paginate.iterator(this.github.repos.listReleases.endpoint.merge(updatedParams));
|
return this.github.paginate.iterator(this.github.repos.listReleases.endpoint.merge(updatedParams));
|
||||||
@ -88,11 +91,29 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi
|
|||||||
finally { if (e_1) throw e_1.error; }
|
finally { if (e_1) throw e_1.error; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let release = yield releaser.getReleaseByTag({
|
let existingRelease = yield releaser.getReleaseByTag({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
tag
|
tag
|
||||||
});
|
});
|
||||||
|
const release_id = existingRelease.data.id;
|
||||||
|
const target_commitish = existingRelease.data.target_commitish;
|
||||||
|
const tag_name = tag;
|
||||||
|
const name = config.input_name || tag;
|
||||||
|
const body = `${existingRelease.data.body}\n${util_1.releaseBody(config)}`;
|
||||||
|
const draft = config.input_draft;
|
||||||
|
const prerelease = config.input_prerelease;
|
||||||
|
const release = yield releaser.updateRelease({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
release_id,
|
||||||
|
tag_name,
|
||||||
|
target_commitish,
|
||||||
|
name,
|
||||||
|
body,
|
||||||
|
draft,
|
||||||
|
prerelease
|
||||||
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
@ -12,9 +12,12 @@ export interface ReleaseAsset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Release {
|
export interface Release {
|
||||||
|
id: number;
|
||||||
upload_url: string;
|
upload_url: string;
|
||||||
html_url: string;
|
html_url: string;
|
||||||
tag_name: string;
|
tag_name: string;
|
||||||
|
body: string;
|
||||||
|
target_commitish: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Releaser {
|
export interface Releaser {
|
||||||
@ -34,6 +37,18 @@ export interface Releaser {
|
|||||||
prerelease: boolean | undefined;
|
prerelease: boolean | undefined;
|
||||||
}): Promise<{ data: Release }>;
|
}): Promise<{ data: Release }>;
|
||||||
|
|
||||||
|
updateRelease(params: {
|
||||||
|
owner: string;
|
||||||
|
repo: string;
|
||||||
|
release_id: number;
|
||||||
|
tag_name: string;
|
||||||
|
target_commitish: string;
|
||||||
|
name: string;
|
||||||
|
body: string | undefined;
|
||||||
|
draft: boolean | undefined;
|
||||||
|
prerelease: boolean | undefined;
|
||||||
|
}): Promise<{ data: Release }>;
|
||||||
|
|
||||||
allReleases(params: {
|
allReleases(params: {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
@ -66,6 +81,20 @@ export class GitHubReleaser implements Releaser {
|
|||||||
return this.github.repos.createRelease(params);
|
return this.github.repos.createRelease(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateRelease(params: {
|
||||||
|
owner: string;
|
||||||
|
repo: string;
|
||||||
|
release_id: number;
|
||||||
|
tag_name: string;
|
||||||
|
target_commitish: string;
|
||||||
|
name: string;
|
||||||
|
body: string | undefined;
|
||||||
|
draft: boolean | undefined;
|
||||||
|
prerelease: boolean | undefined;
|
||||||
|
}): Promise<{ data: Release }> {
|
||||||
|
return this.github.repos.updateRelease(params);
|
||||||
|
}
|
||||||
|
|
||||||
allReleases(params: {
|
allReleases(params: {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
@ -128,11 +157,31 @@ export const release = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let release = await releaser.getReleaseByTag({
|
let existingRelease = await releaser.getReleaseByTag({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
tag
|
tag
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const release_id = existingRelease.data.id;
|
||||||
|
const target_commitish = existingRelease.data.target_commitish;
|
||||||
|
const tag_name = tag;
|
||||||
|
const name = config.input_name || tag;
|
||||||
|
const body = `${existingRelease.data.body}\n${releaseBody(config)}`;
|
||||||
|
const draft = config.input_draft;
|
||||||
|
const prerelease = config.input_prerelease;
|
||||||
|
|
||||||
|
const release = await releaser.updateRelease({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
release_id,
|
||||||
|
tag_name,
|
||||||
|
target_commitish,
|
||||||
|
name,
|
||||||
|
body,
|
||||||
|
draft,
|
||||||
|
prerelease
|
||||||
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status === 404) {
|
if (error.status === 404) {
|
||||||
|
@ -31,9 +31,9 @@ async function run() {
|
|||||||
});
|
});
|
||||||
let rel = await release(config, new GitHubReleaser(gh));
|
let rel = await release(config, new GitHubReleaser(gh));
|
||||||
if (config.input_files) {
|
if (config.input_files) {
|
||||||
const files = paths(config.input_files)
|
const files = paths(config.input_files);
|
||||||
if (files.length == 0) {
|
if (files.length == 0) {
|
||||||
console.warn(`🤔 ${config.input_files} not include valid file.`)
|
console.warn(`🤔 ${config.input_files} not include valid file.`);
|
||||||
}
|
}
|
||||||
files.forEach(async path => {
|
files.forEach(async path => {
|
||||||
await upload(gh, rel.upload_url, path);
|
await upload(gh, rel.upload_url, path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user