Skip to content

Commit c29e202

Browse files
committed
Support globs in artifact file paths
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
1 parent 26ef943 commit c29e202

7 files changed

Lines changed: 53213 additions & 46732 deletions

File tree

release/dist/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39579,14 +39579,22 @@ function getFiles() {
3957939579
if (files === '') {
3958039580
return [];
3958139581
}
39582-
return parse.parseMultiInput(files).map(file => {
39582+
const inputFiles = [];
39583+
for (const file of parse.parseMultiInput(files)) {
39584+
let label;
39585+
let filePath;
3958339586
if (!file.includes(':')) {
39584-
return { label: path_1.default.parse(file).name.toLowerCase(), path: file };
39587+
label = path_1.default.parse(file).name.toLowerCase();
39588+
filePath = file;
3958539589
}
39586-
const [label, ...paths] = file.split(':');
39587-
console.log(`Using label ${label} for file path ${paths.join(':')}`);
39588-
return { label, path: paths.join(':') };
39589-
});
39590+
else {
39591+
label = file.split(':')[0];
39592+
filePath = file.split(':').slice(1).join(':');
39593+
}
39594+
console.log(`Using label ${label} for file path ${filePath}`);
39595+
inputFiles.push({ label, path: filePath });
39596+
}
39597+
return inputFiles;
3959039598
}
3959139599
async function getRelease(inp) {
3959239600
const { api, changes, tag, repoData, success } = inp;

release/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@octokit/core": "5.0.1",
2121
"@octokit/plugin-rest-endpoint-methods": "10.0.0",
2222
"@vermaysha/discord-webhook": "1.4.0",
23+
"glob": "11.0.0",
2324
"markdown-escape": "2.0.0"
2425
},
2526
"devDependencies": {

release/src/action/inputs.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import os from 'os';
77
import path from 'path';
88
import { OctokitApi } from '../types/auth';
99
import markdownEscape from 'markdown-escape';
10+
import { globSync } from 'glob';
1011

1112
export async function getInputs(inp: {api: OctokitApi, repoData: Repo}): Promise<Inputs> {
1213
const { api, repoData } = inp;
@@ -53,16 +54,36 @@ function getFiles(): Inputs.File[] {
5354
return [];
5455
}
5556

56-
return parse.parseMultiInput(files).map(file => {
57+
const inputFiles: Inputs.File[] = [];
58+
59+
for (const file of parse.parseMultiInput(files)) {
60+
let label: string;
61+
let filePath: string;
62+
5763
if (!file.includes(':')) {
58-
return { label: path.parse(file).name.toLowerCase(), path: file };
64+
label = path.parse(file).name.toLowerCase();
65+
filePath = file;
66+
} else {
67+
label = file.split(':')[0];
68+
filePath = file.split(':').slice(1).join(':');
5969
}
6070

61-
const [label, ...paths] = file.split(':');
71+
const files = globSync(filePath);
72+
73+
if (files.length > 1) {
74+
for (const file of files) {
75+
const fileName = path.parse(file).name;
76+
inputFiles.push({ label: `${label}-${fileName}`, path: file });
77+
}
78+
} else if (files.length === 1) {
79+
inputFiles.push({ label, path: files[0] });
80+
} else {
81+
console.log(`File ${label} not found at ${filePath}`);
82+
core.setFailed(`File ${label} not found at ${filePath}`);
83+
}
84+
}
6285

63-
console.log(`Using label ${label} for file path ${paths.join(':')}`);
64-
return { label, path: paths.join(':') };
65-
});
86+
return inputFiles;
6687
}
6788

6889
async function getRelease(inp: {api: OctokitApi, changes: Inputs.Change[], tag: Inputs.Tag, repoData: Repo, success: boolean}): Promise<Inputs.Release> {

0 commit comments

Comments
 (0)