diff --git a/src/publishing/github-publisher.ts b/src/publishing/github-publisher.ts index 7f74632..33599f4 100644 --- a/src/publishing/github-publisher.ts +++ b/src/publishing/github-publisher.ts @@ -6,9 +6,14 @@ import { getFiles } from "../utils/file-utils"; interface GitHubPublisherOptions { tag?: string; token: string; - files: string; + files?: string | { primary?: string, secondary?: string }; } +const defaultFiles = { + primary: "build/libs/!(*-@(dev|sources)).jar", + secondary: "build/libs/*-@(dev|sources).jar" +}; + export default class GitHubPublisher extends Publisher { public get target(): PublisherTarget { return PublisherTarget.GitHub; @@ -30,9 +35,10 @@ export default class GitHubPublisher extends Publisher { throw new Error(`Couldn't find release #${this.options.tag || releaseId}`); } - const files = await getFiles(this.options.files); + const fileSelector = this.options.files && (typeof(this.options.files) === "string" || this.options.files.primary) ? this.options.files : defaultFiles; + const files = await getFiles(fileSelector); if (!files.length) { - throw new Error("Couldn't find specified files"); + throw new Error(`Specified files (${typeof fileSelector === "string" ? fileSelector : fileSelector.primary}) were not found`); } const existingAssets = (await octokit.rest.repos.listReleaseAssets({ ...repo, release_id: releaseId })).data;