add support for prereleases. fixes #17

This commit is contained in:
softprops 2019-09-17 23:30:36 +09:00
parent bd839f3b8f
commit a95bad53b2
7 changed files with 20 additions and 5 deletions

View File

@ -22,6 +22,8 @@ GitHub actions inputs don't inherently support lists of things and one might lik
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
* Add support for prerelease annotated GitHub releases with the new input field `with.prerelease: true`
--- ---
## 0.1.1 ## 0.1.1

View File

@ -25,6 +25,7 @@ describe("util", () => {
input_body: undefined, input_body: undefined,
input_body_path: undefined, input_body_path: undefined,
input_draft: false, input_draft: false,
input_prerelease: false,
input_files: [], input_files: [],
input_name: undefined input_name: undefined
}); });

View File

@ -13,7 +13,10 @@ inputs:
description: 'Gives the release a custom name. Defaults to tag name' description: 'Gives the release a custom name. Defaults to tag name'
required: false required: false
draft: 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 required: false
files: files:
description: 'Newline-delimited list of path globs for asset files to upload' description: 'Newline-delimited list of path globs for asset files to upload'

View File

@ -100,6 +100,7 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi
const name = config.input_name || tag; const name = config.input_name || tag;
const body = config.input_body; const body = config.input_body;
const draft = config.input_draft; const draft = config.input_draft;
const prerelease = config.input_prerelease;
console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`); console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`);
let release = yield releaser.createRelease({ let release = yield releaser.createRelease({
owner, owner,
@ -107,7 +108,8 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi
tag_name, tag_name,
name, name,
body, body,
draft draft,
prerelease
}); });
return release.data; return release.data;
} }

View File

@ -24,7 +24,8 @@ exports.parseConfig = (env) => {
input_body: env.INPUT_BODY, input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH, input_body_path: env.INPUT_BODY_PATH,
input_files: exports.parseInputFiles(env.INPUT_FILES || ""), 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) => { exports.paths = (patterns) => {

View File

@ -31,6 +31,7 @@ export interface Releaser {
name: string; name: string;
body: string | undefined; body: string | undefined;
draft: boolean | undefined; draft: boolean | undefined;
prerelease: boolean | undefined;
}): Promise<{ data: Release }>; }): Promise<{ data: Release }>;
allReleases(params: { allReleases(params: {
@ -60,6 +61,7 @@ export class GitHubReleaser implements Releaser {
name: string; name: string;
body: string | undefined; body: string | undefined;
draft: boolean | undefined; draft: boolean | undefined;
prerelease: boolean | undefined;
}): Promise<{ data: Release }> { }): Promise<{ data: Release }> {
return this.github.repos.createRelease(params); return this.github.repos.createRelease(params);
} }
@ -138,6 +140,7 @@ export const release = async (
const name = config.input_name || tag; const name = config.input_name || tag;
const body = config.input_body; const body = config.input_body;
const draft = config.input_draft; const draft = config.input_draft;
const prerelease = config.input_prerelease;
console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`); console.log(`👩‍🏭 Creating new GitHub release for tag ${tag_name}...`);
let release = await releaser.createRelease({ let release = await releaser.createRelease({
owner, owner,
@ -145,7 +148,8 @@ export const release = async (
tag_name, tag_name,
name, name,
body, body,
draft draft,
prerelease
}); });
return release.data; return release.data;
} catch (error) { } catch (error) {

View File

@ -11,6 +11,7 @@ export interface Config {
input_body_path?: string; input_body_path?: string;
input_files?: string[]; input_files?: string[];
input_draft?: boolean; input_draft?: boolean;
input_prerelease?: boolean;
} }
type Env = { [key: string]: string | undefined }; type Env = { [key: string]: string | undefined };
@ -35,7 +36,8 @@ export const parseConfig = (env: Env): Config => {
input_body: env.INPUT_BODY, input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH, input_body_path: env.INPUT_BODY_PATH,
input_files: parseInputFiles(env.INPUT_FILES || ""), input_files: parseInputFiles(env.INPUT_FILES || ""),
input_draft: env.INPUT_DRAFT === "true" input_draft: env.INPUT_DRAFT === "true",
input_prerelease: env.INPUT_PRERELEASE == "true"
}; };
}; };