|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build and Release |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Set up Go |
| 23 | + uses: actions/setup-go@v5 |
| 24 | + with: |
| 25 | + go-version: "1.21" |
| 26 | + |
| 27 | + - name: Get version |
| 28 | + id: get_version |
| 29 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 30 | + |
| 31 | + - name: Build binaries |
| 32 | + run: | |
| 33 | + # 创建输出目录 |
| 34 | + mkdir -p dist |
| 35 | +
|
| 36 | + # 定义构建函数 |
| 37 | + build() { |
| 38 | + local os=$1 |
| 39 | + local arch=$2 |
| 40 | + local output="dist/sshx-${os}-${arch}" |
| 41 | + |
| 42 | + if [ "$os" = "windows" ]; then |
| 43 | + output="${output}.exe" |
| 44 | + fi |
| 45 | + |
| 46 | + echo "Building for $os/$arch..." |
| 47 | + GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build \ |
| 48 | + -ldflags="-s -w -X main.Version=${{ steps.get_version.outputs.VERSION }}" \ |
| 49 | + -o "$output" \ |
| 50 | + ./cmd/sshx |
| 51 | + |
| 52 | + # 压缩二进制文件 |
| 53 | + if [ "$os" = "windows" ]; then |
| 54 | + zip "dist/sshx-${os}-${arch}.zip" "$output" |
| 55 | + rm "$output" |
| 56 | + else |
| 57 | + tar czf "dist/sshx-${os}-${arch}.tar.gz" -C dist "$(basename $output)" |
| 58 | + rm "$output" |
| 59 | + fi |
| 60 | + } |
| 61 | +
|
| 62 | + # 构建所有平台 |
| 63 | + build linux amd64 |
| 64 | + build linux arm64 |
| 65 | + build darwin amd64 |
| 66 | + build darwin arm64 |
| 67 | + build windows amd64 |
| 68 | +
|
| 69 | + - name: Generate checksums |
| 70 | + run: | |
| 71 | + cd dist |
| 72 | + sha256sum * > checksums.txt |
| 73 | + cat checksums.txt |
| 74 | +
|
| 75 | + - name: Create Release |
| 76 | + uses: softprops/action-gh-release@v1 |
| 77 | + with: |
| 78 | + name: Release ${{ steps.get_version.outputs.VERSION }} |
| 79 | + body: | |
| 80 | + ## SSH & SFTP Remote Tool with MCP Support |
| 81 | +
|
| 82 | + ### 下载说明 |
| 83 | +
|
| 84 | + 请根据您的操作系统选择对应的二进制文件: |
| 85 | +
|
| 86 | + - **Linux (x86_64)**: `sshx-linux-amd64.tar.gz` |
| 87 | + - **Linux (ARM64)**: `sshx-linux-arm64.tar.gz` |
| 88 | + - **macOS (Intel)**: `sshx-darwin-amd64.tar.gz` |
| 89 | + - **macOS (Apple Silicon)**: `sshx-darwin-arm64.tar.gz` |
| 90 | + - **Windows (x86_64)**: `sshx-windows-amd64.zip` |
| 91 | +
|
| 92 | + ### 安装方法 |
| 93 | +
|
| 94 | + #### Linux / macOS |
| 95 | + ```bash |
| 96 | + # 下载并解压 |
| 97 | + tar xzf sshx-<platform>-<arch>.tar.gz |
| 98 | +
|
| 99 | + # 移动到系统路径 |
| 100 | + sudo mv sshx /usr/local/bin/ |
| 101 | +
|
| 102 | + # 赋予执行权限 |
| 103 | + sudo chmod +x /usr/local/bin/sshx |
| 104 | +
|
| 105 | + # 验证安装 |
| 106 | + sshx --help |
| 107 | + ``` |
| 108 | +
|
| 109 | + #### Windows |
| 110 | + ```powershell |
| 111 | + # 解压 zip 文件 |
| 112 | + # 将 sshx.exe 添加到系统 PATH |
| 113 | + # 或直接在解压目录下使用 |
| 114 | + ``` |
| 115 | +
|
| 116 | + ### 功能特性 |
| 117 | +
|
| 118 | + - ✅ SSH 远程命令执行 |
| 119 | + - ✅ SFTP 文件传输(上传/下载/列表/创建目录/删除) |
| 120 | + - ✅ 跨平台密码管理(系统 Keyring) |
| 121 | + - ✅ 命令安全检查(防止危险操作) |
| 122 | + - ✅ MCP (Model Context Protocol) 支持 |
| 123 | + - ✅ Sudo 密码自动填充 |
| 124 | +
|
| 125 | + ### 校验和 |
| 126 | +
|
| 127 | + 请使用 `checksums.txt` 验证下载文件的完整性: |
| 128 | + ```bash |
| 129 | + sha256sum -c checksums.txt |
| 130 | + ``` |
| 131 | +
|
| 132 | + ### 更新日志 |
| 133 | +
|
| 134 | + 查看 [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) 了解详细更新内容。 |
| 135 | +
|
| 136 | + files: | |
| 137 | + dist/* |
| 138 | + draft: false |
| 139 | + prerelease: false |
| 140 | + env: |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + |
| 143 | + - name: Upload artifacts |
| 144 | + uses: actions/upload-artifact@v4 |
| 145 | + with: |
| 146 | + name: binaries |
| 147 | + path: dist/* |
| 148 | + retention-days: 30 |
0 commit comments