chore: bump 1.0.3;发布脚本零配置化
- 版本升级 1.0.2 → 1.0.3 - 脚本不再要求预置环境变量:GITEA_URL 从 git remote origin 推断, GITEA_TOKEN 缺失时自动取 Git Credential Manager 中同一主机的凭证 (与 git 推送同源的 OAuth 凭证,无需另行创建 API token)
This commit is contained in:
Generated
+1
-1
@@ -4135,7 +4135,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mqttx-desktop"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mqttx-desktop"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
edition.workspace = true
|
||||
description = "MQTT X —— 基于 GPUI 的跨平台 MQTT 调试客户端"
|
||||
default-run = "mqttx"
|
||||
|
||||
@@ -48,12 +48,39 @@ try {
|
||||
function Die($msg) { Write-Error "错误: $msg"; exit 1 }
|
||||
|
||||
# ── 必填配置 ────────────────────────────────────────────────────────────────
|
||||
# 地址:优先环境变量,否则从 git remote origin 推断
|
||||
$GiteaUrl = $env:GITEA_URL
|
||||
$Token = $env:GITEA_TOKEN
|
||||
if (-not $GiteaUrl) { Die "缺少环境变量 GITEA_URL(如 https://gitea.example.com)" }
|
||||
if (-not $Token) { Die "缺少环境变量 GITEA_TOKEN(需 package 写权限)" }
|
||||
if (-not $GiteaUrl) {
|
||||
$remote = git -C $Root remote get-url origin 2>$null
|
||||
if ($remote) {
|
||||
if ($remote -match "://") { $hostPart = (($remote -split "://", 2)[-1] -split "/", 2)[0] }
|
||||
else { $hostPart = ($remote -split ":", 2)[0] }
|
||||
$hostPart = ($hostPart -split "@")[-1]
|
||||
if ($hostPart) { $GiteaUrl = "https://$hostPart" }
|
||||
}
|
||||
}
|
||||
if (-not $GiteaUrl) { Die "缺少环境变量 GITEA_URL(如 https://gitea.example.com),且无法从 git remote 推断" }
|
||||
$GiteaUrl = $GiteaUrl.TrimEnd("/")
|
||||
|
||||
# 令牌:优先环境变量,否则取 Git Credential Manager 中同一主机的凭证
|
||||
# (即推送用的那条 OAuth 凭证,无需另行创建 API token)
|
||||
$Token = $env:GITEA_TOKEN
|
||||
if (-not $Token) {
|
||||
try {
|
||||
$env:GIT_TERMINAL_PROMPT = "0"
|
||||
$env:GCM_INTERACTIVE = "Never"
|
||||
$credHost = $GiteaUrl -replace "^https?://", ""
|
||||
$raw = @("protocol=https", "host=$credHost", "") | git credential fill 2>$null
|
||||
$Token = ($raw | Where-Object { $_ -like "password=*" }) -replace "^password=", ""
|
||||
}
|
||||
catch { $Token = $null }
|
||||
finally {
|
||||
Remove-Item Env:GIT_TERMINAL_PROMPT -ErrorAction SilentlyContinue
|
||||
Remove-Item Env:GCM_INTERACTIVE -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
if (-not $Token) { Die "缺少环境变量 GITEA_TOKEN,且无法从 git credential store 自动获取" }
|
||||
|
||||
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$Pkg = if ($PackageName) { $PackageName } elseif ($env:GITEA_PKG) { $env:GITEA_PKG } else { "mqttx" }
|
||||
|
||||
|
||||
@@ -20,11 +20,29 @@ set -euo pipefail
|
||||
|
||||
die() { echo "错误: $*" >&2; exit 1; }
|
||||
|
||||
[ -n "${GITEA_URL:-}" ] || die "缺少 GITEA_URL"
|
||||
[ -n "${GITEA_TOKEN:-}" ] || die "缺少 GITEA_TOKEN"
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
# ── 地址:优先环境变量,否则从 git remote origin 推断 ────────────────────────
|
||||
if [ -z "${GITEA_URL:-}" ]; then
|
||||
remote_url="$(git -C "$ROOT" remote get-url origin 2>/dev/null || true)"
|
||||
case "$remote_url" in
|
||||
*://*) host="${remote_url#*://}"; host="${host%%/*}" ;;
|
||||
*:*) host="${remote_url%%:*}" ;;
|
||||
*) host="" ;;
|
||||
esac
|
||||
host="${host##*@}" # 去掉 git@user@ 前缀
|
||||
[ -n "$host" ] && GITEA_URL="https://$host"
|
||||
fi
|
||||
[ -n "${GITEA_URL:-}" ] || die "缺少 GITEA_URL(或配置 git remote origin)"
|
||||
GITEA_URL="${GITEA_URL%/}"
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
# ── 令牌:优先环境变量,否则取 Git Credential Manager 中同一主机的凭证 ────────
|
||||
if [ -z "${GITEA_TOKEN:-}" ]; then
|
||||
GITEA_TOKEN="$(printf 'protocol=https\nhost=%s\n\n' "${GITEA_URL#*://}" \
|
||||
| GCM_INTERACTIVE=Never GIT_TERMINAL_PROMPT=0 git credential fill 2>/dev/null \
|
||||
| sed -n 's/^password=//p')"
|
||||
[ -n "${GITEA_TOKEN:-}" ] || die "缺少 GITEA_TOKEN,且无法从 git credential store 自动获取"
|
||||
fi
|
||||
PKG="${GITEA_PKG:-mqttx}"
|
||||
|
||||
# ── owner/repo:优先环境变量,其次从 git remote 推断 ─────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user