Skip to content

Commit

Permalink
allow creating draft releases without a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
tesaguri committed Jul 18, 2021
1 parent 5e3f23f commit 0e0e353
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions 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";
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/main.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit 0e0e353

Please sign in to comment.