fix: harden CLI parsing, MCP startup and release integrity

This commit is contained in:
gitea committed 2026-10-17 20:32:36 +08:00
1 parent f0902f5f20
commit 103ead0fe5
53 files changed
+3713 -1945

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.14
- run: bun install --frozen-lockfile
- run: bun run check:version
- run: bun run check
- run: bun test
- run: bun run build:binary
- run: bun run scripts/verify-binary.ts dist/bin/hose-use
- run: bun run build:plugin
- run: git diff --exit-code -- dist/mcp/server.js
- run: bun run scripts/verify-binary.ts dist/mcp/server.js --plugin
+60 -13
View File
@@ -5,26 +5,53 @@ on:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: Release tag already merged into main (e.g. v0.8.14)
required: true
type: string
concurrency:
group: release-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
contents: read
jobs:
build-and-publish:
name: 🚀 Build & Publish Multi-Platform Binaries
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.14
# A tag alone does not prove review. Also verify the commit actually being
# compiled, so manual dispatch cannot validate one tag and ship another ref.
- name: Verify release commit and version
run: |
git fetch --no-tags origin main:refs/remotes/origin/main
bun run scripts/verify-release.ts "$RELEASE_TAG"
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Check committed version consistency
run: bun run check:version
- name: Generate & bundle OpenAPI
run: bun run openapi:all
@@ -37,7 +64,15 @@ jobs:
- name: Compile multi-target binaries
run: |
mkdir -p dist/bin
node scripts/build-binary.mjs --all
node scripts/build-binary.mjs --all --release
- name: Verify packaged MCP entrypoint
run: bun run scripts/verify-binary.ts dist/bin/hose-use-linux-x64
- name: Verify plugin bundle runtime
run: |
bun run build:plugin
bun run scripts/verify-binary.ts dist/mcp/server.js --plugin
- name: Package release archives
run: |
@@ -64,17 +99,19 @@ jobs:
(cd "${stage}" && zip -q "${GITHUB_WORKSPACE}/dist/bin/hose-use-windows-x64.zip" hose-use-windows-x64.exe hose-aipro.cmd)
rm -rf "${stage}"
(cd dist/bin && sha256sum hose-use-* > checksums.txt)
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG_MSG=$(git tag -l --format='%(contents)' "${GITHUB_REF_NAME}" | sed '/^$/d')
TAG_MSG=$(git tag -l --format='%(contents)' "${RELEASE_TAG}" | sed '/^$/d')
if [ -n "$TAG_MSG" ]; then
gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --title "${GITHUB_REF_NAME}" --notes "$TAG_MSG" --generate-notes
gh release view "${RELEASE_TAG}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || gh release create "${RELEASE_TAG}" --repo "${GITHUB_REPOSITORY}" --title "${RELEASE_TAG}" --notes "$TAG_MSG" --generate-notes
else
gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --title "${GITHUB_REF_NAME}" --generate-notes
gh release view "${RELEASE_TAG}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || gh release create "${RELEASE_TAG}" --repo "${GITHUB_REPOSITORY}" --title "${RELEASE_TAG}" --generate-notes
fi
gh release upload "${GITHUB_REF_NAME}" dist/bin/hose-use-* --repo "${GITHUB_REPOSITORY}" --clobber
gh release upload "${RELEASE_TAG}" dist/bin/hose-use-* dist/bin/checksums.txt --repo "${GITHUB_REPOSITORY}" --clobber
- name: Publish Gitea Release
env:
@@ -87,7 +124,7 @@ jobs:
exit 0
fi
TAG_NAME="${GITHUB_REF_NAME}"
TAG_NAME="${RELEASE_TAG}"
TAG_MSG=$(git tag -l --format='%(contents)' "${TAG_NAME}" | sed '/^$/d')
NOTES="${TAG_MSG:-Automated release for ${TAG_NAME}}"
@@ -103,8 +140,8 @@ jobs:
fi
if [ -z "$RELEASE_ID" ]; then
echo "::warning::Failed to create or find Gitea release ID. Response: $RELEASE_RESP"
exit 0
echo "::error::Failed to create or find Gitea release ID. Response: $RELEASE_RESP"
exit 1
fi
echo "==> Uploading assets to Gitea release ID ${RELEASE_ID}..."
@@ -113,7 +150,12 @@ jobs:
local filename
filename=$(basename "$file")
echo " [start] Uploading ${filename} to Gitea..."
RESP=$(curl -s -m 600 -w "\nHTTP_STATUS:%{http_code}" -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \
# Match GitHub --clobber when retrying the same verified release.
existing=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}" | jq -r --arg name "$filename" '.assets[]? | select(.name == $name) | .id')
for asset_id in $existing; do
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets/${asset_id}"
done
RESP=$(curl -fsS -m 600 -w "\nHTTP_STATUS:%{http_code}" -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${file}")
STATUS=$(echo "$RESP" | tail -n 1)
@@ -121,12 +163,17 @@ jobs:
}
pids=()
for file in dist/bin/hose-use-*; do
for file in dist/bin/hose-use-* dist/bin/checksums.txt; do
upload_asset "$file" &
pids+=($!)
done
failed=0
for pid in "${pids[@]}"; do
wait "$pid" || true
wait "$pid" || failed=1
done
if [ "$failed" -ne 0 ]; then
echo "::error::One or more Gitea assets failed to upload."
exit 1
fi
echo "✓ Successfully published release assets to Gitea!"