Skip to content

Commit

Permalink
update make_latest type
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 committed Jul 18, 2024
1 parent c234ec8 commit db980e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 14 additions & 4 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Releaser {
target_commitish: string | undefined;
discussion_category_name: string | undefined;
generate_release_notes: boolean | undefined;
make_latest: string | undefined;
make_latest: "true" | "false" | "legacy" | undefined;
}): Promise<{ data: Release }>;

updateRelease(params: {
Expand All @@ -59,7 +59,7 @@ export interface Releaser {
prerelease: boolean | undefined;
discussion_category_name: string | undefined;
generate_release_notes: boolean | undefined;
make_latest: string | undefined;
make_latest: "true" | "false" | "legacy" | undefined;
}): Promise<{ data: Release }>;

allReleases(params: {
Expand Down Expand Up @@ -93,8 +93,13 @@ export class GitHubReleaser implements Releaser {
target_commitish: string | undefined;
discussion_category_name: string | undefined;
generate_release_notes: boolean | undefined;
make_latest: string | undefined;
make_latest: "true" | "false" | "legacy" | undefined;
}): Promise<{ data: Release }> {

if (typeof params.make_latest === 'string' && !["true", "false", "legacy"].includes(params.make_latest)) {
params.make_latest = undefined;
}

return this.github.rest.repos.createRelease(params);
}

Expand All @@ -110,8 +115,13 @@ export class GitHubReleaser implements Releaser {
prerelease: boolean | undefined;
discussion_category_name: string | undefined;
generate_release_notes: boolean | undefined;
make_latest: string | undefined;
make_latest: "true" | "false" | "legacy" | undefined;
}): Promise<{ data: Release }> {

if (typeof params.make_latest === 'string' && !["true", "false", "legacy"].includes(params.make_latest)) {
params.make_latest = undefined;
}

return this.github.rest.repos.updateRelease(params);
}

Expand Down
15 changes: 11 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface Config {
input_discussion_category_name?: string;
input_generate_release_notes?: boolean;
input_append_body?: boolean;
input_make_latest: string | undefined;
input_make_latest: "true" | "false" | "legacy" | undefined;
}

export const uploadUrl = (url: string): string => {
Expand Down Expand Up @@ -71,12 +71,19 @@ export const parseConfig = (env: Env): Config => {
env.INPUT_DISCUSSION_CATEGORY_NAME || undefined,
input_generate_release_notes: env.INPUT_GENERATE_RELEASE_NOTES == "true",
input_append_body: env.INPUT_APPEND_BODY == "true",
input_make_latest: env.INPUT_MAKE_LATEST
? env.INPUT_MAKE_LATEST
: undefined,
input_make_latest: parseMakeLatest(env.INPUT_MAKE_LATEST),
};
};

const parseMakeLatest = (
value: string | undefined
): "true" | "false" | "legacy" | undefined => {
if (value === "true" || value === "false" || value === "legacy") {
return value;
}
return undefined;
}

export const paths = (patterns: string[]): string[] => {
return patterns.reduce((acc: string[], pattern: string): string[] => {
return acc.concat(
Expand Down

0 comments on commit db980e7

Please sign in to comment.