From a95bad53b2b89bfdc058e7137521300292ac857c Mon Sep 17 00:00:00 2001 From: softprops Date: Tue, 17 Sep 2019 23:30:36 +0900 Subject: [PATCH 1/2] add support for prereleases. fixes #17 --- CHANGELOG.md | 2 ++ __tests__/util.test.ts | 1 + action.yml | 5 ++++- lib/github.js | 4 +++- lib/util.js | 3 ++- src/github.ts | 6 +++++- src/util.ts | 4 +++- 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e21b80f53..7c3c2fe2c 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 3833d41b7..c7cfa4886 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 d7462e45b..65e40232b 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 4ee8eb2e5..d83ef8750 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 3ab6d49f3..e71e3224b 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 6134bc2d7..f42bfd1b8 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 d7682de5c..8dd98197f 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" }; }; From 2984051a429cacca75b88276dfe87d0fc210f9ca Mon Sep 17 00:00:00 2001 From: softprops Date: Tue, 17 Sep 2019 23:33:44 +0900 Subject: [PATCH 2/2] update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 413028398..88976e658 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,8 @@ The following are optional as `step.with` keys | `body` | String | Text communicating notable changes in this release | | `body_path` | String | Path to load text communicating notable changes in this release | | `draft` | Boolean | Indicator of whether or not this release is a draft | -| `files` | String | Newline-delimited globs of paths to assets to upload for release | +| `prerelease`| Boolean | Indicator of whether or not is a prerelease | +| `files` | String | Newline-delimited globs of paths to assets to upload for release| | `name` | String | Name of the release. defaults to tag name | πŸ’‘When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from.