From 688f58f697bfcd7eb3e14dcbd95024d037e5fff3 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sun, 25 Jul 2021 23:10:03 +0000 Subject: [PATCH] allow creating draft releases without a tag (#95) Co-authored-by: Doug Tangren --- src/github.ts | 7 +++++-- src/main.ts | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/github.ts b/src/github.ts index 1cddd80bd..d38448055 100644 --- a/src/github.ts +++ b/src/github.ts @@ -1,5 +1,5 @@ import { GitHub } from "@actions/github"; -import { Config, releaseBody } from "./util"; +import { Config, isTag, releaseBody } from "./util"; import { lstatSync, readFileSync } from "fs"; import { getType } from "mime"; import { basename } from "path"; @@ -154,7 +154,10 @@ export const release = async ( const [owner, repo] = config.github_repository.split("/"); const tag = - config.input_tag_name || config.github_ref.replace("refs/tags/", ""); + config.input_tag_name || + (isTag(config.github_ref) + ? 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 diff --git a/src/main.ts b/src/main.ts index 371fab01e..0239effdd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,7 +7,11 @@ import { env } from "process"; async function run() { try { const config = parseConfig(env); - if (!config.input_tag_name && !isTag(config.github_ref)) { + if ( + !config.input_tag_name && + !isTag(config.github_ref) && + !config.input_draft + ) { throw new Error(`⚠️ GitHub Releases requires a tag`); } if (config.input_files) {