From c3daf8dfe913f0603d7dc0d6d36ecba595fb60a2 Mon Sep 17 00:00:00 2001 From: sesky4 Date: Tue, 12 Aug 2025 15:57:17 +0800 Subject: [PATCH 1/2] feat: use pyinstaller to release binary on every tag --- .github/workflows/binary-release.yml | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/binary-release.yml diff --git a/.github/workflows/binary-release.yml b/.github/workflows/binary-release.yml new file mode 100644 index 0000000000..fe09063b02 --- /dev/null +++ b/.github/workflows/binary-release.yml @@ -0,0 +1,78 @@ +name: Build and Release with PyInstaller + +on: + push: + tags: + - "*" + +jobs: + build: + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Run PyInstaller + run: | + pyinstaller tccli/main.py -y -F --collect-all tccli --exclude-module tccli.examples --name tccli + + - name: Package binary (Linux/macOS) + if: runner.os == 'Linux' + run: | + zip -j "dist/tccli-linux.zip" "dist/tccli" + + - name: Package binary (Linux/macOS) + if: runner.os == 'macOS' + run: | + zip -j "dist/tccli-macos.zip" "dist/tccli" + + - name: Package binary (Windows) + if: runner.os == 'Windows' + run: | + # 在 Windows 上使用 PowerShell 压缩 + Compress-Archive -Path "dist\tccli.exe" -DestinationPath "dist\tccli-windows.zip" + shell: powershell + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: "tccli-${{ runner.os }}" + path: dist/*.zip + + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Create GitHub Release + id: create_release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + name: Release ${{ github.ref_name }} + draft: false + prerelease: false + files: artifacts/*/*.zip \ No newline at end of file From 3349dc4f5637e2698b931c124e7d5eff9cd5d15c Mon Sep 17 00:00:00 2001 From: sesky4 Date: Tue, 26 Aug 2025 11:43:47 +0800 Subject: [PATCH 2/2] Update binary-release.yml --- .github/workflows/binary-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/binary-release.yml b/.github/workflows/binary-release.yml index fe09063b02..3df2c8bb46 100644 --- a/.github/workflows/binary-release.yml +++ b/.github/workflows/binary-release.yml @@ -9,7 +9,7 @@ jobs: build: strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] + os: [ windows-latest ] runs-on: ${{ matrix.os }} @@ -75,4 +75,4 @@ jobs: name: Release ${{ github.ref_name }} draft: false prerelease: false - files: artifacts/*/*.zip \ No newline at end of file + files: artifacts/*/*.zip