Skip to content

Commit e1194c6

Browse files
committed
Support globs in release filenames
Signed-off-by: Joshua Castle <[email protected]>
1 parent 6136c13 commit e1194c6

File tree

14 files changed

+39652
-40288
lines changed

14 files changed

+39652
-40288
lines changed

dist/index.js

Lines changed: 39360 additions & 39430 deletions
Large diffs are not rendered by default.

dist/licenses.txt

Lines changed: 211 additions & 807 deletions
Large diffs are not rendered by default.

dist/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as core from '@actions/core'
2-
import { getInputs } from './src/action/inputs';
3-
import { writeRelease } from './src/action/release';
4-
import { getRepoData } from './src/action/repo';
5-
import { storeReleaseData } from './src/action/store';
6-
import { uploadFiles } from './src/action/files';
7-
import { authGithubApp } from './src/action/auth';
8-
import { sendWebhook } from './src/action/hook';
9-
import { setOutputs } from './src/action/output';
2+
import { getInputs } from './src/action/inputs.js';
3+
import { writeRelease } from './src/action/release.js';
4+
import { getRepoData } from './src/action/repo.js';
5+
import { storeReleaseData } from './src/action/store.js';
6+
import { uploadFiles } from './src/action/files.js';
7+
import { authGithubApp } from './src/action/auth.js';
8+
import { sendWebhook } from './src/action/hook.js';
9+
import { setOutputs } from './src/action/output.js';
1010

1111
async function run(): Promise<void> {
1212
try {

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "base-release-action",
3-
"version": "1.3.5",
3+
"version": "1.4.0",
44
"description": "An action to create incremented releases in a similar style to Jenkins",
55
"repository": "https://github.com/Kas-tle/base-release-action.git",
66
"author": "Joshua Castle <[email protected]>",
@@ -17,18 +17,20 @@
1717
},
1818
"dependencies": {
1919
"@actions/core": "^1.10.1",
20-
"@octokit/auth-app": "^6.0.1",
21-
"@octokit/core": "^5.0.1",
22-
"@octokit/plugin-rest-endpoint-methods": "^10.0.0",
20+
"@octokit/auth-app": "7.1.1",
21+
"@octokit/core": "6.1.2",
22+
"@octokit/plugin-rest-endpoint-methods": "13.2.6",
2323
"@vermaysha/discord-webhook": "^1.4.0",
24+
"glob": "^11.0.0",
2425
"markdown-escape": "^2.0.0",
2526
"tslib": "^2.6.2"
2627
},
2728
"devDependencies": {
2829
"@types/markdown-escape": "^1.1.1",
29-
"@types/node": "^20.7.1",
30+
"@types/node": "22.7.5",
3031
"@vercel/ncc": "^0.38.0",
3132
"js-yaml": "^4.1.0",
3233
"typescript": "^5.2.2"
33-
}
34+
},
35+
"type": "module"
3436
}

src/action/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import crypto from 'crypto';
33
import { createAppAuth } from '@octokit/auth-app';
44
import { Octokit } from '@octokit/core';
55
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods';
6-
import { OctokitApi } from '../types/auth';
7-
import { BaseRepo, Repo } from '../types/repo';
6+
import { OctokitApi } from '../types/auth.js';
7+
import { BaseRepo, Repo } from '../types/repo.js';
88
import { request } from "@octokit/request"
99

1010
export async function authGithubApp(inp: {baseRepoData: BaseRepo}): Promise<{octokit: OctokitApi, repoData: Repo}> {

src/action/files.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import path from "path";
22
import fs from "fs";
3-
import * as parse from "../util/parse";
4-
import { Inputs } from "../types/inputs";
5-
import { ReleaseResponse } from "src/types/release";
6-
import { Repo } from "src/types/repo";
7-
import { FileInfo, UploadInfo } from "../types/files";
3+
import * as parse from "../util/parse.js";
4+
import { Inputs } from "../types/inputs.js";
5+
import { ReleaseResponse } from "src/types/release.js";
6+
import { Repo } from "src/types/repo.js";
7+
import { FileInfo, UploadInfo } from "../types/files.js";
88
import { Readable } from "stream";
9-
import { OctokitApi } from "../types/auth";
9+
import { OctokitApi } from "../types/auth.js";
1010

1111
export async function uploadFiles(inp: {api: OctokitApi, inputs: Inputs, release: ReleaseResponse | null, repoData: Repo}) {
1212
const { api, inputs, release, repoData } = inp;

src/action/hook.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Embed, Webhook } from '@vermaysha/discord-webhook'
2-
import { Inputs } from '../types/inputs';
3-
import { ReleaseResponse } from '../types/release';
4-
import { Repo } from '../types/repo';
5-
import { OctokitApi } from '../types/auth';
2+
import { Inputs } from '../types/inputs.js';
3+
import { ReleaseResponse } from '../types/release.js';
4+
import { Repo } from '../types/repo.js';
5+
import { OctokitApi } from '../types/auth.js';
66

77
export async function sendWebhook(inp: {inputs: Inputs, api: OctokitApi, repoData: Repo, releaseResponse: ReleaseResponse | null}) {
88
const { inputs, api, repoData, releaseResponse } = inp;

src/action/inputs.ts

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as core from '@actions/core'
22
import fs from 'fs';
3-
import { Inputs, PreviousRelease } from '../types/inputs';
4-
import * as parse from '../util/parse';
5-
import { Repo } from '../types/repo';
3+
import { Inputs, PreviousRelease } from '../types/inputs.js';
4+
import * as parse from '../util/parse.js';
5+
import { Repo } from '../types/repo.js';
66
import os from 'os';
77
import path from 'path';
8-
import { OctokitApi } from '../types/auth';
8+
import { OctokitApi } from '../types/auth.js';
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;
@@ -47,18 +48,42 @@ async function getPrevRelease(inp: {api: OctokitApi, repoData: Repo}): Promise<P
4748
}
4849

4950
function getFiles(): Inputs.File[] {
50-
const files = core.getInput('files', { required: true });
51+
const files = core.getInput('files');
52+
53+
if (files === '') {
54+
return [];
55+
}
56+
57+
const inputFiles: Inputs.File[] = [];
58+
59+
for (const file of parse.parseMultiInput(files)) {
60+
let label: string;
61+
let filePath: string;
5162

52-
return parse.parseMultiInput(files).map(file => {
5363
if (!file.includes(':')) {
54-
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(':');
5569
}
5670

57-
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+
}
5885

59-
console.log(`Using label ${label} for file path ${paths.join(':')}`);
60-
return { label, path: paths.join(':') };
61-
});
86+
return inputFiles;
6287
}
6388

6489
async function getRelease(inp: {api: OctokitApi, changes: Inputs.Change[], tag: Inputs.Tag, repoData: Repo, success: boolean}): Promise<Inputs.Release> {
@@ -159,9 +184,9 @@ async function getChanges(inp: {api: OctokitApi, prevRelease: PreviousRelease, r
159184
const timestamp = c.commit.committer && c.commit.committer.date ? new Date(c.commit.committer.date).getTime().toString() : '';
160185
const author = c.author ? c.author.login : '';
161186
const coauthors = c.commit.message.match(/Co-authored-by: (.*) <(.*)>/g)
162-
?.map(coauthor => coauthor.replace(/Co-authored-by: (.*) <(.*)>/, '$1'))
187+
?.map((coauthor) => coauthor.replace(/Co-authored-by: (.*) <(.*)>/, '$1'))
163188
.filter((value, index, array) => array.indexOf(value) === index)
164-
.filter(coauthor => coauthor !== '') ?? [];
189+
.filter((coauthor) => coauthor !== '') ?? [];
165190

166191
changes.push({ commit, summary, message, timestamp, author, coauthors });
167192
}

src/action/output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core'
2-
import { ReleaseResponse } from "../types/release";
3-
import { Inputs } from '../types/inputs';
2+
import { ReleaseResponse } from "../types/release.js";
3+
import { Inputs } from '../types/inputs.js';
44

55
export async function setOutputs(inp: {release: ReleaseResponse | null, inputs: Inputs}): Promise<void> {
66
const { release, inputs } = inp;

src/action/release.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { OctokitApi } from '../types/auth';
2-
import { Inputs } from '../types/inputs';
3-
import { ReleaseResponse } from '../types/release';
4-
import { Repo } from '../types/repo';
1+
import { OctokitApi } from '../types/auth.js';
2+
import { Inputs } from '../types/inputs.js';
3+
import { ReleaseResponse } from '../types/release.js';
4+
import { Repo } from '../types/repo.js';
55

66
export async function writeRelease(inp: {inputs: Inputs, api: OctokitApi, repoData: Repo}): Promise<ReleaseResponse | null> {
77
const { inputs, api, repoData } = inp;

src/action/repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BaseRepo } from "../types/repo";
2-
import * as parse from '../util/parse';
1+
import { BaseRepo } from "../types/repo.js";
2+
import * as parse from '../util/parse.js';
33
import * as core from '@actions/core'
44

55
export function getRepoData(): BaseRepo {

src/action/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { OctokitApi } from '../types/auth';
1+
import { OctokitApi } from '../types/auth.js';
22
import core from '@actions/core';
3-
import { Inputs } from "../types/inputs";
4-
import { Repo } from "../types/repo";
3+
import { Inputs } from "../types/inputs.js";
4+
import { Repo } from "../types/repo.js";
55
import { isDeepStrictEqual } from 'util';
66

77
export async function storeReleaseData(inp: {inputs: Inputs, api: OctokitApi, repoData: Repo}) {

src/types/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { Octokit } from "@octokit/core";
2-
import { Api } from "@octokit/plugin-rest-endpoint-methods/dist-types/types";
2+
import { Api } from "@octokit/plugin-rest-endpoint-methods";
33

44
export type OctokitApi = Octokit & Api;

0 commit comments

Comments
 (0)