Skip to content

Commit ab96419

Browse files
Copilotnpv2k1
andcommitted
Improve error handling for version extraction
Co-authored-by: npv2k1 <73846954+npv2k1@users.noreply.github.com>
1 parent 51276bd commit ab96419

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ jobs:
6666
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
6767
echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT
6868
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
69-
VERSION="v$(node -p "require('./package.json').version" 2>/dev/null || echo "0.0.0")"
70-
if [ "$VERSION" = "vundefined" ] || [ "$VERSION" = "v" ]; then
71-
echo "Error: Unable to extract version from package.json"
69+
if [ ! -f package.json ]; then
70+
echo "Error: package.json not found"
71+
exit 1
72+
fi
73+
VERSION="v$(node -p "require('./package.json').version" 2>/dev/null)"
74+
if [ -z "$VERSION" ] || [ "$VERSION" = "v" ] || [ "$VERSION" = "vundefined" ] || [ "$VERSION" = "vnull" ]; then
75+
echo "Error: Unable to extract valid version from package.json"
7276
exit 1
7377
fi
7478
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)