From d8d4fd16a85937e9e89bb451ec5ffb4d309b623a Mon Sep 17 00:00:00 2001
From: Kir_Antipov <kp.antipov@gmail.com>
Date: Sun, 26 Sep 2021 18:03:10 +0300
Subject: [PATCH] Fixed GitHubPublisher

---
 src/publishing/github-publisher.ts | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

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<GitHubPublisherOptions> {
     public get target(): PublisherTarget {
         return PublisherTarget.GitHub;
@@ -30,9 +35,10 @@ export default class GitHubPublisher extends Publisher<GitHubPublisherOptions> {
             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;