Add tag_name option (#39)

Allow setting tag name like actions/create-release.
This commit is contained in:
K.Takata 2020-01-09 15:06:19 +09:00 committed by Doug Tangren
parent b7e450da2a
commit 9f4852ebe6
7 changed files with 18 additions and 7 deletions

View file

@ -142,7 +142,8 @@ export const release = async (
releaser: Releaser
): Promise<Release> => {
const [owner, repo] = config.github_repository.split("/");
const tag = config.github_ref.replace("refs/tags/", "");
const tag =
config.input_tag_name || config.github_ref.replace("refs/tags/", "");
try {
// you can't get a an existing draft by tag
// so we must find one in the list of all releases

View file

@ -7,7 +7,7 @@ import { env } from "process";
async function run() {
try {
const config = parseConfig(env);
if (!isTag(config.github_ref)) {
if (!config.input_tag_name && !isTag(config.github_ref)) {
throw new Error(`⚠️ GitHub Releases requires a tag`);
}
GitHub.plugin(require("@octokit/plugin-throttling"));

View file

@ -7,6 +7,7 @@ export interface Config {
github_repository: string;
// user provided
input_name?: string;
input_tag_name?: string;
input_body?: string;
input_body_path?: string;
input_files?: string[];
@ -41,6 +42,7 @@ export const parseConfig = (env: Env): Config => {
github_ref: env.GITHUB_REF || "",
github_repository: env.GITHUB_REPOSITORY || "",
input_name: env.INPUT_NAME,
input_tag_name: env.INPUT_TAG_NAME,
input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH,
input_files: parseInputFiles(env.INPUT_FILES || ""),