diff --git a/CHANGELOG.md b/CHANGELOG.md index e21b80f..7c3c2fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ GitHub actions inputs don't inherently support lists of things and one might lik GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` +* Add support for prerelease annotated GitHub releases with the new input field `with.prerelease: true` + --- ## 0.1.1 diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index 3833d41..c7cfa48 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -25,6 +25,7 @@ describe("util", () => { input_body: undefined, input_body_path: undefined, input_draft: false, + input_prerelease: false, input_files: [], input_name: undefined }); diff --git a/action.yml b/action.yml index d7462e4..65e4023 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,10 @@ inputs: description: 'Gives the release a custom name. Defaults to tag name' required: false draft: - description: 'Creates a draft release' + description: 'Creates a draft release. Defaults to false' + required: false + prerelease: + description: 'Identify the release as a prerelease. Defaults to false' required: false files: description: 'Newline-delimited list of path globs for asset files to upload' diff --git a/lib/github.js b/lib/github.js index 4ee8eb2..d83ef87 100644 --- a/lib/github.js +++ b/lib/github.js @@ -100,6 +100,7 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi const name = config.input_name || tag; const body = config.input_body; const draft = config.input_draft; + const prerelease = config.input_prerelease; console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`); let release = yield releaser.createRelease({ owner, @@ -107,7 +108,8 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi tag_name, name, body, - draft + draft, + prerelease }); return release.data; } diff --git a/lib/util.js b/lib/util.js index 3ab6d49..e71e322 100644 --- a/lib/util.js +++ b/lib/util.js @@ -24,7 +24,8 @@ exports.parseConfig = (env) => { input_body: env.INPUT_BODY, input_body_path: env.INPUT_BODY_PATH, input_files: exports.parseInputFiles(env.INPUT_FILES || ""), - input_draft: env.INPUT_DRAFT === "true" + input_draft: env.INPUT_DRAFT === "true", + input_prerelease: env.INPUT_PRERELEASE == "true" }; }; exports.paths = (patterns) => { diff --git a/src/github.ts b/src/github.ts index 6134bc2..f42bfd1 100644 --- a/src/github.ts +++ b/src/github.ts @@ -31,6 +31,7 @@ export interface Releaser { name: string; body: string | undefined; draft: boolean | undefined; + prerelease: boolean | undefined; }): Promise<{ data: Release }>; allReleases(params: { @@ -60,6 +61,7 @@ export class GitHubReleaser implements Releaser { name: string; body: string | undefined; draft: boolean | undefined; + prerelease: boolean | undefined; }): Promise<{ data: Release }> { return this.github.repos.createRelease(params); } @@ -138,6 +140,7 @@ export const release = async ( const name = config.input_name || tag; const body = config.input_body; const draft = config.input_draft; + const prerelease = config.input_prerelease; console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`); let release = await releaser.createRelease({ owner, @@ -145,7 +148,8 @@ export const release = async ( tag_name, name, body, - draft + draft, + prerelease }); return release.data; } catch (error) { diff --git a/src/util.ts b/src/util.ts index d7682de..8dd9819 100644 --- a/src/util.ts +++ b/src/util.ts @@ -11,6 +11,7 @@ export interface Config { input_body_path?: string; input_files?: string[]; input_draft?: boolean; + input_prerelease?: boolean; } type Env = { [key: string]: string | undefined }; @@ -35,7 +36,8 @@ export const parseConfig = (env: Env): Config => { input_body: env.INPUT_BODY, input_body_path: env.INPUT_BODY_PATH, input_files: parseInputFiles(env.INPUT_FILES || ""), - input_draft: env.INPUT_DRAFT === "true" + input_draft: env.INPUT_DRAFT === "true", + input_prerelease: env.INPUT_PRERELEASE == "true" }; };