Merge pull request #23 from softprops/body_path_not_used
honor body_path input when provided.
This commit is contained in:
commit
e7b71cc1a7
1
__tests__/release.txt
Normal file
1
__tests__/release.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
bar
|
@ -1,4 +1,10 @@
|
|||||||
import { isTag, paths, parseConfig, parseInputFiles } from "../src/util";
|
import {
|
||||||
|
releaseBody,
|
||||||
|
isTag,
|
||||||
|
paths,
|
||||||
|
parseConfig,
|
||||||
|
parseInputFiles
|
||||||
|
} from "../src/util";
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
describe("util", () => {
|
describe("util", () => {
|
||||||
@ -16,6 +22,56 @@ describe("util", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe("releaseBody", () => {
|
||||||
|
it("uses input body", () => {
|
||||||
|
assert.equal(
|
||||||
|
"foo",
|
||||||
|
releaseBody({
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
input_body: "foo",
|
||||||
|
input_body_path: undefined,
|
||||||
|
input_draft: false,
|
||||||
|
input_prerelease: false,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it("uses input body path", () => {
|
||||||
|
assert.equal(
|
||||||
|
"bar",
|
||||||
|
releaseBody({
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
input_body: undefined,
|
||||||
|
input_body_path: "__tests__/release.txt",
|
||||||
|
input_draft: false,
|
||||||
|
input_prerelease: false,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it("defaults to body when both body and body path are provided", () => {
|
||||||
|
assert.equal(
|
||||||
|
"foo",
|
||||||
|
releaseBody({
|
||||||
|
github_ref: "",
|
||||||
|
github_repository: "",
|
||||||
|
github_token: "",
|
||||||
|
input_body: "foo",
|
||||||
|
input_body_path: "__tests__/release.txt",
|
||||||
|
input_draft: false,
|
||||||
|
input_prerelease: false,
|
||||||
|
input_files: [],
|
||||||
|
input_name: undefined
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe("parseConfig", () => {
|
describe("parseConfig", () => {
|
||||||
it("parses basic config", () => {
|
it("parses basic config", () => {
|
||||||
assert.deepStrictEqual(parseConfig({}), {
|
assert.deepStrictEqual(parseConfig({}), {
|
||||||
|
@ -16,6 +16,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|||||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const util_1 = require("./util");
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
const mime_1 = require("mime");
|
const mime_1 = require("mime");
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
@ -98,7 +99,7 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi
|
|||||||
try {
|
try {
|
||||||
const tag_name = tag;
|
const tag_name = tag;
|
||||||
const name = config.input_name || tag;
|
const name = config.input_name || tag;
|
||||||
const body = config.input_body;
|
const body = util_1.releaseBody(config);
|
||||||
const draft = config.input_draft;
|
const draft = config.input_draft;
|
||||||
const prerelease = config.input_prerelease;
|
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}...`);
|
||||||
|
@ -9,6 +9,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const glob = __importStar(require("glob"));
|
const glob = __importStar(require("glob"));
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
|
exports.releaseBody = (config) => {
|
||||||
|
return (config.input_body ||
|
||||||
|
(config.input_body_path &&
|
||||||
|
fs_1.readFileSync(config.input_body_path).toString("utf8")));
|
||||||
|
};
|
||||||
exports.parseInputFiles = (files) => {
|
exports.parseInputFiles = (files) => {
|
||||||
return files.split(/\r?\n/).reduce((acc, line) => acc
|
return files.split(/\r?\n/).reduce((acc, line) => acc
|
||||||
.concat(line.split(","))
|
.concat(line.split(","))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { GitHub } from "@actions/github";
|
import { GitHub } from "@actions/github";
|
||||||
import { Config } from "./util";
|
import { Config, releaseBody } from "./util";
|
||||||
import { lstatSync, readFileSync } from "fs";
|
import { lstatSync, readFileSync } from "fs";
|
||||||
import { getType } from "mime";
|
import { getType } from "mime";
|
||||||
import { basename } from "path";
|
import { basename } from "path";
|
||||||
@ -138,7 +138,7 @@ export const release = async (
|
|||||||
try {
|
try {
|
||||||
const tag_name = tag;
|
const tag_name = tag;
|
||||||
const name = config.input_name || tag;
|
const name = config.input_name || tag;
|
||||||
const body = config.input_body;
|
const body = releaseBody(config);
|
||||||
const draft = config.input_draft;
|
const draft = config.input_draft;
|
||||||
const prerelease = config.input_prerelease;
|
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}...`);
|
||||||
|
10
src/util.ts
10
src/util.ts
@ -1,5 +1,5 @@
|
|||||||
import * as glob from "glob";
|
import * as glob from "glob";
|
||||||
import { lstatSync } from "fs";
|
import { lstatSync, readFileSync } from "fs";
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
github_token: string;
|
github_token: string;
|
||||||
@ -14,6 +14,14 @@ export interface Config {
|
|||||||
input_prerelease?: boolean;
|
input_prerelease?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const releaseBody = (config: Config): string | undefined => {
|
||||||
|
return (
|
||||||
|
config.input_body ||
|
||||||
|
(config.input_body_path &&
|
||||||
|
readFileSync(config.input_body_path).toString("utf8"))
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
type Env = { [key: string]: string | undefined };
|
type Env = { [key: string]: string | undefined };
|
||||||
|
|
||||||
export const parseInputFiles = (files: string): string[] => {
|
export const parseInputFiles = (files: string): string[] => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user