Skip to content

Commit

Permalink
new: Add prerelease output. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Aug 12, 2024
1 parent 75db54c commit 155d07f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.4.1

- Added `prerelease` output.
- Fixed handling of prerelease identifiers/suffixes.

# 0.4.0

- Updated tag parsing to support prerelease metadata.
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ jobs:
artifacts: builds/*
artifactErrorsFailBuild: true
body: ${{ steps.build.outputs.changelog-entry }}
prerelease:
${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') ||
contains(github.ref_name, '-rc') }}
prerelease: ${{ steps.build.outputs.prerelease == 'true' }}
skipIfReleaseExists: true
```
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ outputs:
description: 'The project affected by a Git tag, if applicable.'
tagged-version:
description: 'The extracted version from a Git tag, if applicable.'
prerelease:
description: 'Whether the extracted version is a pre-release or not.'
8 changes: 6 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ function detectVersionAndProject() {
const tag = ref.replace('refs/tags/', '');
let project = '';
let version = '';
let prerelease = false;

core.info(`Detected tag ${tag}`);
TAG = tag;

const regex = /^(?:(?<project>[\w-]+)[@-])?(?<version>v?\d+\.\d+\.\d+)(?<suffix>[\w+.-]+)?$/i;
const regex = /^(?:(?<project>[\w-]+)[@-])?(?<version>v?\d+\.\d+\.\d+(?<suffix>[\w+.-]+)?)$/i;
const match = tag.match(regex);

if (match?.groups) {
({ project = '', version = ''} = match.groups);
({ project = '', version = '' } = match.groups);
prerelease = !!match.groups?.suffix;
} else {
version = tag;
}
Expand All @@ -54,6 +56,7 @@ function detectVersionAndProject() {

core.info(`Detected tagged version ${version}`);
core.setOutput('tagged-version', version);
core.setOutput('prerelease', prerelease);

PLUGIN_VERSION = version;

Expand Down Expand Up @@ -277,6 +280,7 @@ async function run() {
core.setOutput('changelog-entry', '');
core.setOutput('tagged-project', '');
core.setOutput('tagged-version', '');
core.setOutput('prerelease', 'false');

try {
detectVersionAndProject();
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.4.0",
"version": "0.4.1",
"description": "A GitHub action to build, optimize, and prepare WASM plugins for release.",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 155d07f

Please sign in to comment.