From f692f013f33cc2927f4fce7ed7122c80d6b33a97 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:01:19 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 199 ++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7bf1e5d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,199 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' # 当推送以 v 开头的标签时触发,如 v1.0.0 + workflow_dispatch: # 允许手动触发 + +env: + GO_VERSION: '1.23' + PROJECT_NAME: 'golin' + +jobs: + build: + name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + # Windows builds + - goos: windows + goarch: amd64 + os: windows-latest + ext: '.exe' + + - goos: windows + goarch: arm64 + os: windows-latest + ext: '.exe' + + # Linux builds + - goos: linux + goarch: amd64 + os: ubuntu-latest + ext: '' + + - goos: linux + goarch: arm64 + os: ubuntu-latest + ext: '' + + # macOS builds + - goos: darwin + goarch: amd64 + os: macos-latest + ext: '' + + - goos: darwin + goarch: arm64 + os: macos-latest + ext: '' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Get dependencies + run: go mod download + + - name: Build binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + run: | + mkdir -p dist + go build -ldflags="-s -w" -o dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} . + + - name: Create archive (Windows) + if: matrix.goos == 'windows' + run: | + cd dist + 7z a ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} + + - name: Create archive (Unix) + if: matrix.goos != 'windows' + run: | + cd dist + tar -czf ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} + path: | + dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip + dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz + retention-days: 1 + + release: + name: Create Release + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Prepare release assets + run: | + mkdir -p release-assets + find artifacts -name "*.zip" -o -name "*.tar.gz" | xargs -I {} cp {} release-assets/ + ls -la release-assets/ + + - name: Generate checksums + run: | + cd release-assets + sha256sum * > checksums.txt + cat checksums.txt + + - name: Get tag name + id: tag + run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag.outputs.tag }} + name: Release ${{ steps.tag.outputs.tag }} + draft: false + prerelease: false + generate_release_notes: true + files: | + release-assets/* + body: | + ## 🚀 Release ${{ steps.tag.outputs.tag }} + + ### 📦 Downloads + + Choose the appropriate binary for your platform: + + #### Windows + - **AMD64**: `${{ env.PROJECT_NAME }}-windows-amd64.zip` + - **ARM64**: `${{ env.PROJECT_NAME }}-windows-arm64.zip` + + #### Linux + - **AMD64**: `${{ env.PROJECT_NAME }}-linux-amd64.tar.gz` + - **ARM64**: `${{ env.PROJECT_NAME }}-linux-arm64.tar.gz` + + #### macOS + - **Intel (AMD64)**: `${{ env.PROJECT_NAME }}-darwin-amd64.tar.gz` + - **Apple Silicon (ARM64)**: `${{ env.PROJECT_NAME }}-darwin-arm64.tar.gz` + + ### 🔐 Verification + + All binaries are provided with SHA256 checksums in `checksums.txt`. + + ### 📋 Installation + + 1. Download the appropriate binary for your platform + 2. Extract the archive + 3. Make the binary executable (Unix systems): `chmod +x golin` + 4. Run: `./golin --help` + + --- + + **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ steps.tag.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + cleanup: + name: Cleanup artifacts + needs: release + runs-on: ubuntu-latest + if: always() + + steps: + - name: Delete artifacts + uses: geekyeggo/delete-artifact@v5 + with: + name: | + ${{ env.PROJECT_NAME }}-windows-amd64 + ${{ env.PROJECT_NAME }}-windows-arm64 + ${{ env.PROJECT_NAME }}-linux-amd64 + ${{ env.PROJECT_NAME }}-linux-arm64 + ${{ env.PROJECT_NAME }}-darwin-amd64 + ${{ env.PROJECT_NAME }}-darwin-arm64 + failOnError: false From 45bf486867dbedc9f1a1f8e27ffd70d6fbd539f2 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:03:22 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 199 ---------------------------------- 1 file changed, 199 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7bf1e5d..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,199 +0,0 @@ -name: Build and Release - -on: - push: - tags: - - 'v*' # 当推送以 v 开头的标签时触发,如 v1.0.0 - workflow_dispatch: # 允许手动触发 - -env: - GO_VERSION: '1.23' - PROJECT_NAME: 'golin' - -jobs: - build: - name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - # Windows builds - - goos: windows - goarch: amd64 - os: windows-latest - ext: '.exe' - - - goos: windows - goarch: arm64 - os: windows-latest - ext: '.exe' - - # Linux builds - - goos: linux - goarch: amd64 - os: ubuntu-latest - ext: '' - - - goos: linux - goarch: arm64 - os: ubuntu-latest - ext: '' - - # macOS builds - - goos: darwin - goarch: amd64 - os: macos-latest - ext: '' - - - goos: darwin - goarch: arm64 - os: macos-latest - ext: '' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Get dependencies - run: go mod download - - - name: Build binary - env: - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - CGO_ENABLED: 0 - run: | - mkdir -p dist - go build -ldflags="-s -w" -o dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} . - - - name: Create archive (Windows) - if: matrix.goos == 'windows' - run: | - cd dist - 7z a ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} - - - name: Create archive (Unix) - if: matrix.goos != 'windows' - run: | - cd dist - tar -czf ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} - path: | - dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip - dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz - retention-days: 1 - - release: - name: Create Release - needs: build - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: Prepare release assets - run: | - mkdir -p release-assets - find artifacts -name "*.zip" -o -name "*.tar.gz" | xargs -I {} cp {} release-assets/ - ls -la release-assets/ - - - name: Generate checksums - run: | - cd release-assets - sha256sum * > checksums.txt - cat checksums.txt - - - name: Get tag name - id: tag - run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ steps.tag.outputs.tag }} - name: Release ${{ steps.tag.outputs.tag }} - draft: false - prerelease: false - generate_release_notes: true - files: | - release-assets/* - body: | - ## 🚀 Release ${{ steps.tag.outputs.tag }} - - ### 📦 Downloads - - Choose the appropriate binary for your platform: - - #### Windows - - **AMD64**: `${{ env.PROJECT_NAME }}-windows-amd64.zip` - - **ARM64**: `${{ env.PROJECT_NAME }}-windows-arm64.zip` - - #### Linux - - **AMD64**: `${{ env.PROJECT_NAME }}-linux-amd64.tar.gz` - - **ARM64**: `${{ env.PROJECT_NAME }}-linux-arm64.tar.gz` - - #### macOS - - **Intel (AMD64)**: `${{ env.PROJECT_NAME }}-darwin-amd64.tar.gz` - - **Apple Silicon (ARM64)**: `${{ env.PROJECT_NAME }}-darwin-arm64.tar.gz` - - ### 🔐 Verification - - All binaries are provided with SHA256 checksums in `checksums.txt`. - - ### 📋 Installation - - 1. Download the appropriate binary for your platform - 2. Extract the archive - 3. Make the binary executable (Unix systems): `chmod +x golin` - 4. Run: `./golin --help` - - --- - - **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ steps.tag.outputs.tag }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cleanup: - name: Cleanup artifacts - needs: release - runs-on: ubuntu-latest - if: always() - - steps: - - name: Delete artifacts - uses: geekyeggo/delete-artifact@v5 - with: - name: | - ${{ env.PROJECT_NAME }}-windows-amd64 - ${{ env.PROJECT_NAME }}-windows-arm64 - ${{ env.PROJECT_NAME }}-linux-amd64 - ${{ env.PROJECT_NAME }}-linux-arm64 - ${{ env.PROJECT_NAME }}-darwin-amd64 - ${{ env.PROJECT_NAME }}-darwin-arm64 - failOnError: false From 14d90ea63794f6825d033f700cb059da6eb2e21c Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:03:33 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 199 ++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7bf1e5d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,199 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' # 当推送以 v 开头的标签时触发,如 v1.0.0 + workflow_dispatch: # 允许手动触发 + +env: + GO_VERSION: '1.23' + PROJECT_NAME: 'golin' + +jobs: + build: + name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + # Windows builds + - goos: windows + goarch: amd64 + os: windows-latest + ext: '.exe' + + - goos: windows + goarch: arm64 + os: windows-latest + ext: '.exe' + + # Linux builds + - goos: linux + goarch: amd64 + os: ubuntu-latest + ext: '' + + - goos: linux + goarch: arm64 + os: ubuntu-latest + ext: '' + + # macOS builds + - goos: darwin + goarch: amd64 + os: macos-latest + ext: '' + + - goos: darwin + goarch: arm64 + os: macos-latest + ext: '' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Get dependencies + run: go mod download + + - name: Build binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + run: | + mkdir -p dist + go build -ldflags="-s -w" -o dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} . + + - name: Create archive (Windows) + if: matrix.goos == 'windows' + run: | + cd dist + 7z a ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} + + - name: Create archive (Unix) + if: matrix.goos != 'windows' + run: | + cd dist + tar -czf ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} + path: | + dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip + dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz + retention-days: 1 + + release: + name: Create Release + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Prepare release assets + run: | + mkdir -p release-assets + find artifacts -name "*.zip" -o -name "*.tar.gz" | xargs -I {} cp {} release-assets/ + ls -la release-assets/ + + - name: Generate checksums + run: | + cd release-assets + sha256sum * > checksums.txt + cat checksums.txt + + - name: Get tag name + id: tag + run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag.outputs.tag }} + name: Release ${{ steps.tag.outputs.tag }} + draft: false + prerelease: false + generate_release_notes: true + files: | + release-assets/* + body: | + ## 🚀 Release ${{ steps.tag.outputs.tag }} + + ### 📦 Downloads + + Choose the appropriate binary for your platform: + + #### Windows + - **AMD64**: `${{ env.PROJECT_NAME }}-windows-amd64.zip` + - **ARM64**: `${{ env.PROJECT_NAME }}-windows-arm64.zip` + + #### Linux + - **AMD64**: `${{ env.PROJECT_NAME }}-linux-amd64.tar.gz` + - **ARM64**: `${{ env.PROJECT_NAME }}-linux-arm64.tar.gz` + + #### macOS + - **Intel (AMD64)**: `${{ env.PROJECT_NAME }}-darwin-amd64.tar.gz` + - **Apple Silicon (ARM64)**: `${{ env.PROJECT_NAME }}-darwin-arm64.tar.gz` + + ### 🔐 Verification + + All binaries are provided with SHA256 checksums in `checksums.txt`. + + ### 📋 Installation + + 1. Download the appropriate binary for your platform + 2. Extract the archive + 3. Make the binary executable (Unix systems): `chmod +x golin` + 4. Run: `./golin --help` + + --- + + **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ steps.tag.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + cleanup: + name: Cleanup artifacts + needs: release + runs-on: ubuntu-latest + if: always() + + steps: + - name: Delete artifacts + uses: geekyeggo/delete-artifact@v5 + with: + name: | + ${{ env.PROJECT_NAME }}-windows-amd64 + ${{ env.PROJECT_NAME }}-windows-arm64 + ${{ env.PROJECT_NAME }}-linux-amd64 + ${{ env.PROJECT_NAME }}-linux-arm64 + ${{ env.PROJECT_NAME }}-darwin-amd64 + ${{ env.PROJECT_NAME }}-darwin-arm64 + failOnError: false From 4915daf2c032ebf51de6c908f8ba7c2337687186 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:11:23 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 63 +++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bf1e5d..aa042fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,7 @@ jobs: name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false # 不要因为一个失败就取消所有构建 matrix: include: # Windows builds @@ -22,32 +23,32 @@ jobs: goarch: amd64 os: windows-latest ext: '.exe' - + - goos: windows goarch: arm64 os: windows-latest ext: '.exe' - + # Linux builds - goos: linux goarch: amd64 os: ubuntu-latest ext: '' - + - goos: linux goarch: arm64 os: ubuntu-latest ext: '' - + # macOS builds - goos: darwin goarch: amd64 - os: macos-latest + os: macos-13 # 使用稳定的 macOS 版本 ext: '' - + - goos: darwin goarch: arm64 - os: macos-latest + os: macos-14 # 使用支持 ARM64 的 macOS 版本 ext: '' steps: @@ -72,14 +73,21 @@ jobs: - name: Get dependencies run: go mod download + - name: Verify Go installation + run: | + go version + go env GOOS GOARCH + - name: Build binary env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 run: | + echo "Building for ${{ matrix.goos }}/${{ matrix.goarch }}" mkdir -p dist - go build -ldflags="-s -w" -o dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} . + go build -v -ldflags="-s -w" -o dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} . + ls -la dist/ - name: Create archive (Windows) if: matrix.goos == 'windows' @@ -106,7 +114,7 @@ jobs: name: Create Release needs: build runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') && always() # 即使部分构建失败也继续 steps: - name: Checkout code @@ -116,24 +124,53 @@ jobs: uses: actions/download-artifact@v4 with: path: artifacts + continue-on-error: true - name: Prepare release assets run: | mkdir -p release-assets - find artifacts -name "*.zip" -o -name "*.tar.gz" | xargs -I {} cp {} release-assets/ - ls -la release-assets/ + echo "Available artifacts:" + find artifacts -type f 2>/dev/null || echo "No artifacts directory found" + + # 复制所有可用的压缩包 + find artifacts -name "*.zip" -o -name "*.tar.gz" 2>/dev/null | while read file; do + echo "Copying: $file" + cp "$file" release-assets/ 2>/dev/null || echo "Failed to copy $file" + done + + echo "Release assets:" + ls -la release-assets/ || echo "No release assets found" - name: Generate checksums run: | cd release-assets - sha256sum * > checksums.txt - cat checksums.txt + if [ "$(ls -A .)" ]; then + sha256sum * > checksums.txt + echo "Generated checksums:" + cat checksums.txt + else + echo "No files to generate checksums for" + echo "# No release assets available" > checksums.txt + fi - name: Get tag name id: tag run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + - name: Check if we have assets to release + id: check_assets + run: | + cd release-assets + if [ "$(ls -A . | grep -v checksums.txt)" ]; then + echo "has_assets=true" >> $GITHUB_OUTPUT + echo "Found assets to release" + else + echo "has_assets=false" >> $GITHUB_OUTPUT + echo "No assets found to release" + fi + - name: Create Release + if: steps.check_assets.outputs.has_assets == 'true' uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.tag.outputs.tag }} From 2f32392d9fbb1004b670703482159a9ebff25cc4 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:23:10 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 263 ++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 149 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa042fb..7291295 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,54 +2,85 @@ name: Build and Release on: push: - tags: - - 'v*' # 当推送以 v 开头的标签时触发,如 v1.0.0 - workflow_dispatch: # 允许手动触发 + branches: [ main, master ] + tags: [ 'v*' ] + pull_request: + branches: [ main, master ] env: GO_VERSION: '1.23' - PROJECT_NAME: 'golin' + APP_NAME: 'golin' jobs: + # 代码质量检查 + test: + name: Test and Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod download + + - name: Run tests + run: go test -v ./... + + - name: Run go vet + run: go vet ./... + + - name: Run go fmt check + run: | + if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then + echo "Code is not formatted properly:" + gofmt -s -l . + exit 1 + fi + + # 构建多平台版本 build: - name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} - runs-on: ${{ matrix.os }} + name: Build + needs: test + runs-on: ubuntu-latest strategy: - fail-fast: false # 不要因为一个失败就取消所有构建 matrix: include: - # Windows builds + # Windows - goos: windows goarch: amd64 - os: windows-latest - ext: '.exe' - + suffix: .exe - goos: windows goarch: arm64 - os: windows-latest - ext: '.exe' - - # Linux builds + suffix: .exe + # Linux - goos: linux goarch: amd64 - os: ubuntu-latest - ext: '' - + suffix: "" - goos: linux goarch: arm64 - os: ubuntu-latest - ext: '' - - # macOS builds + suffix: "" + # macOS - goos: darwin goarch: amd64 - os: macos-13 # 使用稳定的 macOS 版本 - ext: '' - + suffix: "" - goos: darwin goarch: arm64 - os: macos-14 # 使用支持 ARM64 的 macOS 版本 - ext: '' + suffix: "" steps: - name: Checkout code @@ -70,13 +101,19 @@ jobs: restore-keys: | ${{ runner.os }}-go- - - name: Get dependencies + - name: Download dependencies run: go mod download - - name: Verify Go installation + - name: Get version + id: version run: | - go version - go env GOOS GOARCH + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + else + VERSION=${GITHUB_SHA::8} + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Building version: $VERSION" - name: Build binary env: @@ -84,38 +121,34 @@ jobs: GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 run: | - echo "Building for ${{ matrix.goos }}/${{ matrix.goarch }}" - mkdir -p dist - go build -v -ldflags="-s -w" -o dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} . - ls -la dist/ + BINARY_NAME="${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}" + echo "Building $BINARY_NAME" - - name: Create archive (Windows) - if: matrix.goos == 'windows' - run: | - cd dist - 7z a ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} + # 设置构建标志 + LDFLAGS="-s -w -X main.version=${{ steps.version.outputs.version }}" - - name: Create archive (Unix) - if: matrix.goos != 'windows' - run: | - cd dist - tar -czf ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} + go build -ldflags="$LDFLAGS" -o "$BINARY_NAME" . + + # 验证二进制文件 + if [ "${{ matrix.goos }}" = "linux" ] && [ "${{ matrix.goarch }}" = "amd64" ]; then + file "$BINARY_NAME" + ls -la "$BINARY_NAME" + fi - - name: Upload artifacts + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: - name: ${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} - path: | - dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip - dist/${{ env.PROJECT_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz - retention-days: 1 + name: ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} + path: ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }} + retention-days: 30 + # 发布版本(仅在推送标签时) release: name: Create Release needs: build runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') && always() # 即使部分构建失败也继续 - + if: startsWith(github.ref, 'refs/tags/') + steps: - name: Checkout code uses: actions/checkout@v4 @@ -123,114 +156,46 @@ jobs: - name: Download all artifacts uses: actions/download-artifact@v4 with: - path: artifacts - continue-on-error: true + path: ./artifacts - - name: Prepare release assets + - name: Get version + id: version run: | - mkdir -p release-assets - echo "Available artifacts:" - find artifacts -type f 2>/dev/null || echo "No artifacts directory found" - - # 复制所有可用的压缩包 - find artifacts -name "*.zip" -o -name "*.tar.gz" 2>/dev/null | while read file; do - echo "Copying: $file" - cp "$file" release-assets/ 2>/dev/null || echo "Failed to copy $file" - done + VERSION=${GITHUB_REF#refs/tags/} + echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Release assets:" - ls -la release-assets/ || echo "No release assets found" - - - name: Generate checksums + - name: Prepare release files run: | - cd release-assets - if [ "$(ls -A .)" ]; then - sha256sum * > checksums.txt - echo "Generated checksums:" - cat checksums.txt - else - echo "No files to generate checksums for" - echo "# No release assets available" > checksums.txt - fi - - - name: Get tag name - id: tag - run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + mkdir -p release + cd artifacts + for dir in */; do + if [ -d "$dir" ]; then + cp "$dir"/* ../release/ 2>/dev/null || true + fi + done + cd ../release + ls -la - - name: Check if we have assets to release - id: check_assets + - name: Generate checksums run: | - cd release-assets - if [ "$(ls -A . | grep -v checksums.txt)" ]; then - echo "has_assets=true" >> $GITHUB_OUTPUT - echo "Found assets to release" - else - echo "has_assets=false" >> $GITHUB_OUTPUT - echo "No assets found to release" - fi + cd release + for file in *; do + if [ -f "$file" ] && [ "$file" != "checksums.txt" ]; then + sha256sum "$file" >> checksums.txt + fi + done + echo "Generated checksums:" + cat checksums.txt - name: Create Release - if: steps.check_assets.outputs.has_assets == 'true' uses: softprops/action-gh-release@v2 with: - tag_name: ${{ steps.tag.outputs.tag }} - name: Release ${{ steps.tag.outputs.tag }} + tag_name: ${{ steps.version.outputs.version }} + name: Release ${{ steps.version.outputs.version }} draft: false prerelease: false generate_release_notes: true files: | - release-assets/* - body: | - ## 🚀 Release ${{ steps.tag.outputs.tag }} - - ### 📦 Downloads - - Choose the appropriate binary for your platform: - - #### Windows - - **AMD64**: `${{ env.PROJECT_NAME }}-windows-amd64.zip` - - **ARM64**: `${{ env.PROJECT_NAME }}-windows-arm64.zip` - - #### Linux - - **AMD64**: `${{ env.PROJECT_NAME }}-linux-amd64.tar.gz` - - **ARM64**: `${{ env.PROJECT_NAME }}-linux-arm64.tar.gz` - - #### macOS - - **Intel (AMD64)**: `${{ env.PROJECT_NAME }}-darwin-amd64.tar.gz` - - **Apple Silicon (ARM64)**: `${{ env.PROJECT_NAME }}-darwin-arm64.tar.gz` - - ### 🔐 Verification - - All binaries are provided with SHA256 checksums in `checksums.txt`. - - ### 📋 Installation - - 1. Download the appropriate binary for your platform - 2. Extract the archive - 3. Make the binary executable (Unix systems): `chmod +x golin` - 4. Run: `./golin --help` - - --- - - **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ steps.tag.outputs.tag }} + release/* env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cleanup: - name: Cleanup artifacts - needs: release - runs-on: ubuntu-latest - if: always() - - steps: - - name: Delete artifacts - uses: geekyeggo/delete-artifact@v5 - with: - name: | - ${{ env.PROJECT_NAME }}-windows-amd64 - ${{ env.PROJECT_NAME }}-windows-arm64 - ${{ env.PROJECT_NAME }}-linux-amd64 - ${{ env.PROJECT_NAME }}-linux-arm64 - ${{ env.PROJECT_NAME }}-darwin-amd64 - ${{ env.PROJECT_NAME }}-darwin-arm64 - failOnError: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b9be0d9486844b456a4fa7ae84d4e95262eb81cf Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:26:12 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=EF=BC=8C=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 13 ++++++++++++- run/windows/netstat.go | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7291295..d79313c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,13 @@ jobs: run: go mod download - name: Run tests - run: go test -v ./... + run: | + # 运行测试,如果没有测试文件则跳过 + if find . -name "*_test.go" | grep -q .; then + go test -v ./... + else + echo "No test files found, skipping tests" + fi - name: Run go vet run: go vet ./... @@ -52,6 +58,11 @@ jobs: exit 1 fi + - name: Build check + run: | + # 验证代码可以编译 + go build -v . + # 构建多平台版本 build: name: Build diff --git a/run/windows/netstat.go b/run/windows/netstat.go index 51f1d1c..ef1a9ba 100644 --- a/run/windows/netstat.go +++ b/run/windows/netstat.go @@ -1,3 +1,5 @@ +//go:build windows + package windows import ( From b347bc7d0825e84c617ab6dafbeaebb5e1ce1e78 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:32:54 +0800 Subject: [PATCH 07/11] =?UTF-8?q?m=E6=B7=BB=E5=8A=A0mac=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/keylogger_darwin.go | 22 ++++++++++++++++++++++ cmd/wifi_darwin.go | 22 ++++++++++++++++++++++ cmd/windows_darwin.go | 22 ++++++++++++++++++++++ run/navicat/navicat_darwin.go | 7 +++++++ run/windows/windows_darwin.go | 9 +++++++++ run/xshell/xshell_darwin.go | 7 +++++++ 6 files changed, 89 insertions(+) create mode 100644 cmd/keylogger_darwin.go create mode 100644 cmd/wifi_darwin.go create mode 100644 cmd/windows_darwin.go create mode 100644 run/navicat/navicat_darwin.go create mode 100644 run/windows/windows_darwin.go create mode 100644 run/xshell/xshell_darwin.go diff --git a/cmd/keylogger_darwin.go b/cmd/keylogger_darwin.go new file mode 100644 index 0000000..c04312b --- /dev/null +++ b/cmd/keylogger_darwin.go @@ -0,0 +1,22 @@ +//go:build darwin + +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" +) + +// keyloggerCmd represents the keylogger command for macOS +var keyloggerCmd = &cobra.Command{ + Use: "keylogger", + Short: "键盘记录器 (macOS 不支持)", + Long: `键盘记录器功能在 macOS 上不可用`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("键盘记录器功能在 macOS 上不可用") + }, +} + +func init() { + rootCmd.AddCommand(keyloggerCmd) +} diff --git a/cmd/wifi_darwin.go b/cmd/wifi_darwin.go new file mode 100644 index 0000000..9c2ea7f --- /dev/null +++ b/cmd/wifi_darwin.go @@ -0,0 +1,22 @@ +//go:build darwin + +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" +) + +// wifiCmd represents the wifi command for macOS +var wifiCmd = &cobra.Command{ + Use: "wifi", + Short: "WiFi 密码获取 (macOS 不支持)", + Long: `WiFi 密码获取功能在 macOS 上不可用`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("WiFi 密码获取功能在 macOS 上不可用") + }, +} + +func init() { + rootCmd.AddCommand(wifiCmd) +} diff --git a/cmd/windows_darwin.go b/cmd/windows_darwin.go new file mode 100644 index 0000000..bbad7cc --- /dev/null +++ b/cmd/windows_darwin.go @@ -0,0 +1,22 @@ +//go:build darwin + +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" +) + +// windowsCmd represents the windows command for macOS +var windowsCmd = &cobra.Command{ + Use: "windows", + Short: "Windows 安全策略检查 (macOS 不支持)", + Long: `Windows 安全策略检查功能在 macOS 上不可用`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("Windows 安全策略检查功能在 macOS 上不可用") + }, +} + +func init() { + rootCmd.AddCommand(windowsCmd) +} diff --git a/run/navicat/navicat_darwin.go b/run/navicat/navicat_darwin.go new file mode 100644 index 0000000..cd9a454 --- /dev/null +++ b/run/navicat/navicat_darwin.go @@ -0,0 +1,7 @@ +//go:build darwin + +package navicat + +import "github.com/spf13/cobra" + +func Run(cmd *cobra.Command, args []string) { return } diff --git a/run/windows/windows_darwin.go b/run/windows/windows_darwin.go new file mode 100644 index 0000000..da89fb3 --- /dev/null +++ b/run/windows/windows_darwin.go @@ -0,0 +1,9 @@ +//go:build darwin + +package windows + +// Windows 函数的 macOS 占位符实现 +func Windows() { + // macOS 上不执行任何操作 + return +} diff --git a/run/xshell/xshell_darwin.go b/run/xshell/xshell_darwin.go new file mode 100644 index 0000000..96c36ea --- /dev/null +++ b/run/xshell/xshell_darwin.go @@ -0,0 +1,7 @@ +//go:build darwin + +package xshell + +import "github.com/spf13/cobra" + +func Run(cmd *cobra.Command, args []string) { return } From eb0e86bfae0fcad891d2ae0fe6c48ca1108627a2 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:36:47 +0800 Subject: [PATCH 08/11] =?UTF-8?q?github.com/iamacarpet/go-win64api=20?= =?UTF-8?q?=E4=B8=8D=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/user_users.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/user_users.go b/cmd/user_users.go index 6d7f79a..6f04fd1 100644 --- a/cmd/user_users.go +++ b/cmd/user_users.go @@ -1,4 +1,4 @@ -//go:build windows +//go:build windows && amd64 package cmd From c2602dce5991dd1bd362d1a1ff619cdaadd6f3cc Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:44:00 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E7=BC=96=E8=AF=91=E7=BC=93=E5=AD=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 56 ++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d79313c..43ecdb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,15 +25,16 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + # 暂时禁用缓存以避免 tar 错误 + # - name: Cache Go modules + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-v2 + # restore-keys: | + # ${{ runner.os }}-go- - name: Download dependencies run: go mod download @@ -102,15 +103,16 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + # 暂时禁用缓存以避免 tar 错误 + # - name: Cache Go modules + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-v2 + # restore-keys: | + # ${{ runner.os }}-go- - name: Download dependencies run: go mod download @@ -153,12 +155,12 @@ jobs: path: ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }} retention-days: 30 - # 发布版本(仅在推送标签时) + # 发布版本(标签时正式发布,主分支时预发布) release: name: Create Release needs: build runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) steps: - name: Checkout code @@ -172,8 +174,15 @@ jobs: - name: Get version id: version run: | - VERSION=${GITHUB_REF#refs/tags/} + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + echo "is_prerelease=false" >> $GITHUB_OUTPUT + else + VERSION="dev-${GITHUB_SHA::8}" + echo "is_prerelease=true" >> $GITHUB_OUTPUT + fi echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Building version: $VERSION" - name: Prepare release files run: | @@ -202,10 +211,11 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.version.outputs.version }} - name: Release ${{ steps.version.outputs.version }} + name: ${{ steps.version.outputs.is_prerelease == 'true' && format('Pre-release {0}', steps.version.outputs.version) || format('Release {0}', steps.version.outputs.version) }} draft: false - prerelease: false + prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }} generate_release_notes: true + body: ${{ steps.version.outputs.is_prerelease == 'true' && '⚠️ 这是一个开发版本,可能不稳定。仅用于测试目的。' || '' }} files: | release/* env: From d4ba26e0f0fa4e9f4dde2c9d5812610bcb632ce0 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:46:29 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E7=BC=96=E8=AF=91=E7=BC=93=E5=AD=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43ecdb7..5fbde78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,19 +25,11 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - # 暂时禁用缓存以避免 tar 错误 - # - name: Cache Go modules - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-v2 - # restore-keys: | - # ${{ runner.os }}-go- - - name: Download dependencies - run: go mod download + run: | + # 清理可能损坏的缓存 + go clean -modcache || true + go mod download - name: Run tests run: | @@ -103,19 +95,11 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - # 暂时禁用缓存以避免 tar 错误 - # - name: Cache Go modules - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-v2 - # restore-keys: | - # ${{ runner.os }}-go- - - name: Download dependencies - run: go mod download + run: | + # 清理可能损坏的缓存 + go clean -modcache || true + go mod download - name: Get version id: version From 892630a21dbc93f7271c2fc034e1598fe7625341 Mon Sep 17 00:00:00 2001 From: RuoJi6 <79234113+RuoJi6@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:51:41 +0800 Subject: [PATCH 11/11] win arm bug --- cmd/user_users_arm64.go | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 cmd/user_users_arm64.go diff --git a/cmd/user_users_arm64.go b/cmd/user_users_arm64.go new file mode 100644 index 0000000..a4a6172 --- /dev/null +++ b/cmd/user_users_arm64.go @@ -0,0 +1,51 @@ +//go:build windows && arm64 + +package cmd + +import ( + "fmt" + "github.com/olekukonko/tablewriter" + "github.com/spf13/cobra" + "os" + "os/exec" + "strings" +) + +var userCmd = &cobra.Command{ + Use: "users", + Short: "获取用户信息 (Windows ARM64 简化版)", + Run: checkusers, +} + +func init() { + rootCmd.AddCommand(userCmd) +} + +func checkusers(cmd *cobra.Command, args []string) { + // 使用 PowerShell 命令获取用户信息,因为 go-win64api 不支持 ARM64 + psCmd := `Get-LocalUser | Select-Object Name, FullName, Enabled, LastLogon, UserMayChangePassword, PasswordRequired | Format-Table -AutoSize` + + execCmd := exec.Command("powershell", "-Command", psCmd) + output, err := execCmd.CombinedOutput() + if err != nil { + fmt.Printf("\033[31m错误:获取用户列表失败 (%v)\033[0m\n", err) + return + } + + fmt.Println("Windows ARM64 用户信息 (通过 PowerShell 获取):") + fmt.Println(strings.TrimSpace(string(output))) + + // 简化的表格显示 + table := tablewriter.NewWriter(os.Stdout) + table.SetAutoFormatHeaders(false) + table.SetHeader([]string{ + "说明", + "状态", + }) + + table.Append([]string{"用户信息获取方式", "PowerShell (ARM64 兼容)"}) + table.Append([]string{"详细信息", "请查看上方 PowerShell 输出"}) + table.Append([]string{"注意", "ARM64 版本功能有限"}) + + table.Render() +}