Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow creating draft releases without a tag #95

Merged
merged 2 commits into from Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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