Skip to content

Commit 745b580

Browse files
committed
fix: workflow fix
Signed-off-by: sarthakjdev <jsarthak448@gmail.com>
1 parent 0d4ac68 commit 745b580

4 files changed

Lines changed: 45 additions & 18 deletions

File tree

.github/workflows/format-tag.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Format Tag'
2+
description: 'Formats a git tag to remove potentially prefixes'
3+
inputs:
4+
tag:
5+
description: 'The input tag'
6+
required: true
7+
outputs:
8+
subpackage:
9+
description: 'Whether this tag is a subpackage tag'
10+
package:
11+
description: 'The package string that was extracted from this tag'
12+
semver:
13+
description: 'The semver string that was extracted from this tag'
14+
runs:
15+
using: node20
16+
main: ../../dist/formatTag/index.js
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export function formatTag(tag: string) {
2+
const parsed = /(?:^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
3+
const parsedPackage = /(?<package>.*)@v?-?.*/.exec(tag);
4+
5+
if (parsed?.groups) {
6+
const isSubPackage = typeof parsed.groups.package === 'string';
7+
const pkg = isSubPackage ? parsed.groups.package : parsedPackage?.groups?.package ?? 'discord.js';
8+
const semver = parsed.groups.semver;
9+
10+
return {
11+
isSubpackage: isSubPackage,
12+
package: pkg,
13+
semver,
14+
};
15+
}
16+
17+
return null;
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { getInput, setOutput } from '@actions/core';
2+
import { formatTag } from './formatTag.js';
3+
4+
const tag = getInput('tag', { required: true });
5+
const parsed = formatTag(tag);
6+
7+
if (parsed) {
8+
setOutput('subpackage', parsed.isSubpackage);
9+
setOutput('package', parsed.package);
10+
setOutput('semver', parsed.semver);
11+
}

0 commit comments

Comments
 (0)