fix
This commit is contained in:
parent
6109b6c8b6
commit
35f350769a
80
.github/actions/compare-bun-version/action.yml
vendored
80
.github/actions/compare-bun-version/action.yml
vendored
@ -1,28 +1,86 @@
|
|||||||
name: ⚖️ Compare Bun Version
|
name: ⚖️ Compare Bun Version
|
||||||
description: Compare the version of Bun to a specified version
|
description: Compare the installed Bun version against a version specification.
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
bun-version:
|
bun-version:
|
||||||
description: The version of Bun to compare against
|
description: The version spec to compare against (e.g., '1.1.0', 'canary', '>1.2.0', '1.x').
|
||||||
required: true
|
required: true
|
||||||
default: "1.1.0"
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: 🛠️ Get installed Bun version
|
- name: 🛠️ Get installed Bun version and revision
|
||||||
id: bun
|
id: bun
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
bun --version
|
echo "version=$(bun --version | tr -d '\r\n')" >> $GITHUB_OUTPUT
|
||||||
echo "version=$(bun --version)" >> $GITHUB_OUTPUT
|
echo "revision=$(bun --revision 2>/dev/null || true)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: ⚖️ Compare versions
|
- name: ⚖️ Compare versions
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
REQUESTED_SPEC: ${{ inputs.bun-version }}
|
||||||
|
ACTUAL_VERSION: ${{ steps.bun.outputs.version }}
|
||||||
|
ACTUAL_REVISION: ${{ steps.bun.outputs.revision }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.bun.outputs.version }}" == "${{ inputs.bun-version }}" ]]; then
|
set -euo pipefail
|
||||||
echo "Version is ${{ inputs.bun-version }}"
|
|
||||||
else
|
# Function to compare two semantic versions (e.g., version_compare 1.2.3 1.10.0)
|
||||||
echo "Expected version to be ${{ inputs.bun-version }}, got ${{ steps.bun.outputs.version }}"
|
# Returns: 0 if v1 == v2, 1 if v1 > v2, 2 if v1 < v2
|
||||||
exit 1
|
version_compare() {
|
||||||
|
if [[ "$1" == "$2" ]]; then return 0; fi
|
||||||
|
local lowest=$(printf '%s\n' "$1" "$2" | sort -V | head -n1)
|
||||||
|
if [[ "$1" == "$lowest" ]]; then return 2; else return 1; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Requested spec: ${REQUESTED_SPEC}"
|
||||||
|
echo "Actual version: ${ACTUAL_VERSION}"
|
||||||
|
|
||||||
|
# Case 1: 'latest' - always passes
|
||||||
|
if [[ "${REQUESTED_SPEC}" == "latest" ]]; then
|
||||||
|
echo "OK: Skipping explicit version check for 'latest'."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Case 2: 'canary' - check for 'canary' in revision or version string
|
||||||
|
if [[ "${REQUESTED_SPEC}" == "canary" ]]; then
|
||||||
|
if [[ "${ACTUAL_REVISION}" == *canary* ]] || [[ "${ACTUAL_VERSION}" == *canary* ]]; then
|
||||||
|
echo "OK: Detected canary build (version: ${ACTUAL_VERSION}, revision: ${ACTUAL_REVISION:-n/a})."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Error: Expected a canary build, but got ${ACTUAL_VERSION} (revision: ${ACTUAL_REVISION:-n/a})."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Case 3: Semver ranges (e.g., >1.0.0, <2, 1.x, 1.1.0)
|
||||||
|
op_part=$(echo "${REQUESTED_SPEC}" | sed -E 's/^([><=]*).*/\1/')
|
||||||
|
version_part=$(echo "${REQUESTED_SPEC}" | sed -E 's/^[><=]*//')
|
||||||
|
op="${op_part:-==}"
|
||||||
|
version_base="${version_part//.x/}"
|
||||||
|
|
||||||
|
# Handle wildcards like '1.x' or '1'
|
||||||
|
if [[ "${version_part}" == *.x* ]] || [[ ! "${version_part}" == *.* ]]; then
|
||||||
|
if [[ "${ACTUAL_VERSION}" == "${version_base}" || "${ACTUAL_VERSION}" == "${version_base}".* ]]; then
|
||||||
|
echo "OK: Version ${ACTUAL_VERSION} matches wildcard spec '${REQUESTED_SPEC}'."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Error: Version ${ACTUAL_VERSION} does not match wildcard spec '${REQUESTED_SPEC}'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Perform comparison for >, <, >=, <=, ==
|
||||||
|
version_compare "${ACTUAL_VERSION}" "${version_part}"
|
||||||
|
result=$?
|
||||||
|
|
||||||
|
case "${op}" in
|
||||||
|
'==') if [[ ${result} -ne 0 ]]; then echo "Error: Expected version ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||||
|
'>') if [[ ${result} -ne 1 ]]; then echo "Error: Expected version > ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||||
|
'<') if [[ ${result} -ne 2 ]]; then echo "Error: Expected version < ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||||
|
'>=') if [[ ${result} -eq 2 ]]; then echo "Error: Expected version >= ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||||
|
'<=') if [[ ${result} -eq 1 ]]; then echo "Error: Expected version <= ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||||
|
*) echo "Error: Unsupported operator '${op}' in spec '${REQUESTED_SPEC}'." && exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "OK: Version ${ACTUAL_VERSION} satisfies spec '${REQUESTED_SPEC}'."
|
||||||
|
|||||||
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
@ -82,6 +82,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
bun --version
|
bun --version
|
||||||
|
|
||||||
|
- name: ⚖️ Verify Bun version
|
||||||
|
uses: ./.github/actions/compare-bun-version
|
||||||
|
with:
|
||||||
|
bun-version: ${{ matrix.bun-version }}
|
||||||
|
|
||||||
setup-bun-from-file:
|
setup-bun-from-file:
|
||||||
name: setup-bun from (${{ matrix.os }}, ${{ matrix.file.name }})
|
name: setup-bun from (${{ matrix.os }}, ${{ matrix.file.name }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|||||||
const { os, arch, avx2, profile, token } = options;
|
const { os, arch, avx2, profile, token } = options;
|
||||||
|
|
||||||
const name = `bun-${os ?? getPlatform()}-${arch ?? getArchitecture()}${
|
const name = `bun-${os ?? getPlatform()}-${arch ?? getArchitecture()}${
|
||||||
avx2 ? "" : "-baseline"
|
avx2 == false ? "-baseline" : ""
|
||||||
}${profile ? "-profile" : ""}`;
|
}${profile ? "-profile" : ""}`;
|
||||||
|
|
||||||
const artifact = artifacts.artifacts.find((item) => item.name === name);
|
const artifact = artifacts.artifacts.find((item) => item.name === name);
|
||||||
@ -128,7 +128,7 @@ async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|||||||
const eversion = encodeURIComponent(tag ?? version);
|
const eversion = encodeURIComponent(tag ?? version);
|
||||||
const eos = encodeURIComponent(os ?? getPlatform());
|
const eos = encodeURIComponent(os ?? getPlatform());
|
||||||
const earch = encodeURIComponent(arch ?? getArchitecture());
|
const earch = encodeURIComponent(arch ?? getArchitecture());
|
||||||
const eavx2 = encodeURIComponent(avx2 == true ? "-baseline" : "");
|
const eavx2 = encodeURIComponent(avx2 == false ? "-baseline" : "");
|
||||||
const eprofile = encodeURIComponent(profile == true ? "-profile" : "");
|
const eprofile = encodeURIComponent(profile == true ? "-profile" : "");
|
||||||
|
|
||||||
const { href } = new URL(
|
const { href } = new URL(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user