Skip to content

Commit

Permalink
new: Use regex for tag matching. (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Aug 8, 2024
1 parent 02468d7 commit 75db54c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.4.0

- Updated tag parsing to support prerelease metadata.
- Updated binaryen to v118.
- Updated wabt to v1.0.36.

# 0.3.3

- Updated binaryen to v117.
Expand Down
24 changes: 9 additions & 15 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ interface BuildInfo {
optLevel: string;
}

const BINARYEN_VERSION = '117';
const WABT_VERSION = '1.0.35';
const BINARYEN_VERSION = '118';
const WABT_VERSION = '1.0.36';

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

// project-v1.0.0
if (tag.includes('-')) {
[project, version] = tag.split('-', 2);
}

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

// v1.0.0
else {
if (match?.groups) {
({ project = '', version = ''} = match.groups);
} else {
version = tag;
}

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

core.info(`Built ${build.packageName}`);
core.info(`\tPlugin file: ${checksumFile}`);
core.info(`\tChecksum file: ${outputFile}`);
core.info(`\tPlugin file: ${outputFile}`);
core.info(`\tChecksum file: ${checksumFile}`);
core.info(`\tChecksum: ${checksumHash}`);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonrepo/build-wasm-plugin",
"version": "0.3.3",
"version": "0.4.0",
"description": "A GitHub action to build, optimize, and prepare WASM plugins for release.",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 75db54c

Please sign in to comment.