name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
default: "v1.4.3"
publish_to_crates:
description: "Publish to crates.io"
required: false
default: "false"
type: choice
options:
- "true"
- "false"
create_github_release:
description: "Create GitHub Release"
required: false
default: "true"
type: choice
options:
- "true"
- "false"
env:
CARGO_TERM_COLOR: always
jobs:
pre-release-check:
name: 发布前检查
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: 缓存 Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-release-check-${{ hashFiles('**/Cargo.lock') }}
- name: 完整的发布前检查
run: make pre-release
build:
name: 构建 ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: pre-release-check
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
steps:
- uses: actions/checkout@v4
- name: 安装 Rust
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: 缓存 Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}
- name: 构建发布版本
run: cargo build --release --target ${{ matrix.target }} --features config-management,interactive-debug
- name: 准备发布文件 (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p releases
cp target/${{ matrix.target }}/release/xqpath releases/xqpath-${{ matrix.target }}
tar -czf releases/xqpath-${{ matrix.target }}.tar.gz -C releases xqpath-${{ matrix.target }}
- name: 准备发布文件 (Windows)
if: runner.os == 'Windows'
run: |
mkdir releases
copy target\${{ matrix.target }}\release\xqpath.exe releases\xqpath-${{ matrix.target }}.exe
powershell Compress-Archive -Path releases\xqpath-${{ matrix.target }}.exe -DestinationPath releases\xqpath-${{ matrix.target }}.zip
- name: 上传发布文件
uses: actions/upload-artifact@v4
with:
name: xqpath-${{ matrix.target }}
path: releases/*
publish-crates:
name: 发布到 crates.io
runs-on: ubuntu-latest
needs: build
if: |
(github.event_name == 'release') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_crates == 'true')
steps:
- uses: actions/checkout@v4
- name: 安装 Rust
uses: dtolnay/rust-toolchain@stable
- name: 缓存 Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-publish-${{ hashFiles('**/Cargo.lock') }}
- name: 验证发布前检查
run: |
echo "🔍 执行发布前验证..."
cargo check --all-features
cargo test --all-features --quiet
- name: 发布到 crates.io
run: |
echo "📦 发布到 crates.io..."
cargo publish --token ${{ secrets.CRATES_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
create-release:
name: 创建 GitHub Release
runs-on: ubuntu-latest
needs: build
if: |
(github.event_name == 'release') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.create_github_release == 'true')
steps:
- uses: actions/checkout@v4
- name: 下载所有构建产物
uses: actions/download-artifact@v4
- name: 准备发布文件
run: |
echo "📦 准备发布文件..."
find . -name "xqpath-*" -type f
ls -la */
- name: 创建 Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version || github.ref_name }}
name: XQPath ${{ github.event.inputs.version || github.ref_name }}
body: |
## XQPath ${{ github.event.inputs.version || github.ref_name }}
### 🎯 主要特性
- ✅ 配置管理系统 (YAML配置支持)
- ✅ 交互式调试器 (15+调试命令)
- ✅ 14个CLI命令全功能支持
- ✅ 132个测试用例,100%通过率
- ✅ 跨平台支持 (Linux, Windows, macOS)
### 📦 下载
选择适合您平台的二进制文件:
- **Linux (x86_64)**: `xqpath-x86_64-unknown-linux-gnu.tar.gz`
- **Windows (x86_64)**: `xqpath-x86_64-pc-windows-msvc.zip`
- **macOS (x86_64)**: `xqpath-x86_64-apple-darwin.tar.gz`
- **macOS (ARM64)**: `xqpath-aarch64-apple-darwin.tar.gz`
### 🚀 安装方式
#### 通过 Cargo 安装
```bash
cargo install xqpath
```
#### 下载二进制文件
```bash
# Linux
wget https://github.com/ThneS/xqpath/releases/download/${{ github.event.inputs.version || github.ref_name }}/xqpath-x86_64-unknown-linux-gnu.tar.gz
tar -xzf xqpath-x86_64-unknown-linux-gnu.tar.gz
# macOS (使用 curl)
curl -L -o xqpath-x86_64-apple-darwin.tar.gz https://github.com/ThneS/xqpath/releases/download/${{ github.event.inputs.version || github.ref_name }}/xqpath-x86_64-apple-darwin.tar.gz
tar -xzf xqpath-x86_64-apple-darwin.tar.gz
```
### 📚 使用示例
```bash
# 基本查询
echo '{"users": [{"name": "Alice"}]}' | xqpath get 'users[*].name'
# 配置管理
xqpath config show
xqpath config set debug.level trace
# 交互式调试
xqpath interactive-debug -f data.json
```
---
**完整文档**: https://github.com/ThneS/xqpath/blob/main/README.md
files: |
**/xqpath-*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}