allow creating draft releases without a tag

This commit is contained in:
Daiki Mizukami 2021-04-19 23:52:24 +09:00
parent 5e3f23f92c
commit 0e0e353877
No known key found for this signature in database
GPG key ID: 10478E598B944AA2
3 changed files with 11 additions and 4 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
import { GitHub } from "@actions/github"; import { GitHub } from "@actions/github";
import { Config, releaseBody } from "./util"; import { Config, isTag, 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";
@ -154,7 +154,10 @@ export const release = async (
const [owner, repo] = config.github_repository.split("/"); const [owner, repo] = config.github_repository.split("/");
const tag = 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 { try {
// you can't get a an existing draft by tag // you can't get a an existing draft by tag
// so we must find one in the list of all releases // so we must find one in the list of all releases

View file

@ -7,7 +7,11 @@ import { env } from "process";
async function run() { async function run() {
try { try {
const config = parseConfig(env); 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`); throw new Error(`⚠️ GitHub Releases requires a tag`);
} }
if (config.input_files) { if (config.input_files) {