Skip to content

Commit 75db54c

Browse files
authored
new: Use regex for tag matching. (#6)
1 parent 02468d7 commit 75db54c

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.4.0
2+
3+
- Updated tag parsing to support prerelease metadata.
4+
- Updated binaryen to v118.
5+
- Updated wabt to v1.0.36.
6+
17
# 0.3.3
28

39
- Updated binaryen to v117.

index.ts

+9-15
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ interface BuildInfo {
1616
optLevel: string;
1717
}
1818

19-
const BINARYEN_VERSION = '117';
20-
const WABT_VERSION = '1.0.35';
19+
const BINARYEN_VERSION = '118';
20+
const WABT_VERSION = '1.0.36';
2121

2222
function getRoot(): string {
2323
return process.env.GITHUB_WORKSPACE!;
@@ -39,18 +39,12 @@ function detectVersionAndProject() {
3939
core.info(`Detected tag ${tag}`);
4040
TAG = tag;
4141

42-
// project-v1.0.0
43-
if (tag.includes('-')) {
44-
[project, version] = tag.split('-', 2);
45-
}
46-
47-
// project@v1.0.0
48-
else if (tag.includes('@')) {
49-
[project, version] = tag.split('@', 2);
50-
}
42+
const regex = /^(?:(?<project>[\w-]+)[@-])?(?<version>v?\d+\.\d+\.\d+)(?<suffix>[\w+.-]+)?$/i;
43+
const match = tag.match(regex);
5144

52-
// v1.0.0
53-
else {
45+
if (match?.groups) {
46+
({ project = '', version = ''} = match.groups);
47+
} else {
5448
version = tag;
5549
}
5650

@@ -241,8 +235,8 @@ async function buildPackages(builds: BuildInfo[]) {
241235
await fs.promises.writeFile(checksumFile, checksumHash);
242236

243237
core.info(`Built ${build.packageName}`);
244-
core.info(`\tPlugin file: ${checksumFile}`);
245-
core.info(`\tChecksum file: ${outputFile}`);
238+
core.info(`\tPlugin file: ${outputFile}`);
239+
core.info(`\tChecksum file: ${checksumFile}`);
246240
core.info(`\tChecksum: ${checksumHash}`);
247241
}
248242

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moonrepo/build-wasm-plugin",
3-
"version": "0.3.3",
3+
"version": "0.4.0",
44
"description": "A GitHub action to build, optimize, and prepare WASM plugins for release.",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)