fix release file

This commit is contained in:
Kernel Builder 2026-01-01 18:25:54 +01:00
parent 81b32a491e
commit 1712844313
No known key found for this signature in database
GPG key ID: 163FE39F7772D2EC

View file

@ -5,15 +5,6 @@ on:
branches: branches:
- main - main
workflow_dispatch: workflow_dispatch:
inputs:
release_name:
description: 'Custom Release Name (e.g., "Jolly", "Christmas")'
required: true
type: string
release_tag:
description: 'Release Tag (e.g., "v1.0.0")'
required: true
type: string
jobs: jobs:
release: release:
@ -38,38 +29,33 @@ jobs:
run: bun install run: bun install
shell: bash shell: bash
- name: Determine Release Info - name: Extract version
id: release_info id: extract
run: | run: |
# For workflow_dispatch, use the provided inputs # Extract major.minor.patch version from scripts/build.mjs
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then # This locates the first quoted three-segment version string in the build script (e.g. "1.1.7")
release_name="${{ github.event.inputs.release_name }}" if [ ! -f scripts/build.mjs ]; then
release_tag="${{ github.event.inputs.release_tag }}" echo "scripts/build.mjs not found" >&2
else exit 1
# For push events, extract version and generate a name fi
if [ ! -f scripts/build.mjs ]; then # Print a snippet of the file for debugging in workflow logs
echo "scripts/build.mjs not found" >&2 echo '--- scripts/build.mjs (snippet) ---' >&2
exit 1 sed -n '1,200p' scripts/build.mjs >&2 || true
fi
# Extract version # Primary extraction: find the first quoted semver (may include prerelease suffix, but we strip it)
raw=$(grep -m1 -oE '\"[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?\"' scripts/build.mjs | tr -d '\"' | head -n1 || true) raw=$(grep -m1 -oE '\"[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?\"' scripts/build.mjs | tr -d '\"' | head -n1 || true)
version=$(printf '%s' "$raw" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
if ! printf '%s' "$version" | grep -xE '^[0-9]+\.[0-9]+\.[0-9]+$' >/dev/null; then # Strip any prerelease suffix, keep only major.minor.patch
echo "Failed to extract a valid base version from scripts/build.mjs" >&2 version=$(printf '%s' "$raw" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
exit 1
fi
# Use version-based naming for push events # Validate final result is exactly major.minor.patch
release_name="Release v${version}" if ! printf '%s' "$version" | grep -xE '^[0-9]+\.[0-9]+\.[0-9]+$' >/dev/null; then
release_tag="v${version}" echo "Failed to extract a valid base version from scripts/build.mjs" >&2
sed -n '1,200p' scripts/build.mjs >&2 || true
exit 1
fi fi
echo "release_name=${release_name}" >> $GITHUB_OUTPUT echo "version=$version" >> $GITHUB_OUTPUT
echo "release_tag=${release_tag}" >> $GITHUB_OUTPUT
echo "Using release name: ${release_name}" >&2
echo "Using release tag: ${release_tag}" >&2
shell: bash shell: bash
- name: Prepare tag - name: Prepare tag
@ -79,7 +65,9 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
tag="${{ steps.release_info.outputs.release_tag }}" # Use the extracted version directly as the tag for main branch releases
version="${{ steps.extract.outputs.version }}"
tag="${version}"
echo "[debug] computed tag=${tag}" >&2 echo "[debug] computed tag=${tag}" >&2
@ -107,8 +95,8 @@ jobs:
- name: Create Release - name: Create Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
tag_name: ${{ steps.release_info.outputs.release_tag }} tag_name: ${{ steps.prepare.outputs.tag }}
name: ${{ steps.release_info.outputs.release_name }} name: Release ${{ steps.prepare.outputs.tag }}
files: | files: |
dist/shiggycord.js dist/shiggycord.js
dist/shiggycord.min.js dist/shiggycord.min.js