From a6a2288f0569d52a60b4d0512f038da3684e32d4 Mon Sep 17 00:00:00 2001 From: Soltus Date: Tue, 2 Apr 2024 10:03:48 +0800 Subject: [PATCH] 6 --- .github/workflows/cd.yml | 65 ++++++++++++++++++++++------------------ app/package.json | 2 +- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index cb55ee7654..13bc0dc25a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -242,37 +242,44 @@ jobs: working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app - name: Upload Release Asset via REST API + if: contains( matrix.config.goos, 'linux') run: | - asset_name="Sillot-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}" - asset_path="${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/build/Sillot-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}" - upload_url="{{ needs.create_release.outputs.upload_url }}" - # Calculate the asset size - if [[ "$RUNNER_OS" == "Linux" ]]; then - asset_size=$(stat -c%s "$asset_path") - else - asset_size=$(Get-Item$asset_path).Length - fi - # Generate the POST URL with asset name - post_url="$upload_url?name=$asset_name" - # Send the POST request with asset data - if [[ "$RUNNER_OS" == "Linux" ]]; then - curl \ - -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Content-Type: application/octet-stream" \ - --data-binary "@$asset_path" \ - -H "Content-Length: $asset_size" \ - "$post_url" - else - Invoke-WebRequest -Uri $post_url -Method Post -Headers @{ - "Authorization" = "token $env:GITHUB_TOKEN"; - "Content-Type" = "application/octet-stream"; - "Content-Length" = $asset_size - } -InFile $asset_path - fi + asset_name="Sillot-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}" + asset_path="${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/build/Sillot-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}" + upload_url="{{ needs.create_release.outputs.upload_url }}" + # Calculate the asset size + asset_size=$(stat -c%s "$asset_path") + # Generate the POST URL with asset name + post_url="$upload_url?name=$asset_name" + # Send the POST request with asset data + curl \ + -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/octet-stream" \ + --data-binary "@$asset_path" \ + -H "Content-Length: $asset_size" \ + "$post_url" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: sh # 在 Windows 上会使用 PowerShell Core 来执行脚本, 兼容大多数 sh 脚本命令 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Release Asset via REST API + if: contains( matrix.config.goos, 'windows') + run: | + $asset_name = "Sillot-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}" + $asset_path = "${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/build/Sillot-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}" + $upload_url = "${{ needs.create_release.outputs.upload_url }}" + # Calculate the asset size + $asset_size = (Get-Item$asset_path).Length + # Generate the POST URL with asset name + $post_url = "$upload_url?name=$asset_name" + # Send the POST request with asset data + Invoke-WebRequest -Uri $post_url -Method Post -Headers @{ + "Authorization" = "token $env:GITHUB_TOKEN"; + "Content-Type" = "application/octet-stream"; + "Content-Length" = $asset_size + } -InFile $asset_path + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh - name: zip WinPortable uses: thedoctor0/zip-release@0.7.1 diff --git a/app/package.json b/app/package.json index 915c0e3fb5..0a5c23e23b 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "sillot", - "version": "0.28.10", + "version": "0.28.11", "syv": "3.0.6", "sypv": "3.0.5", "description": "Build Your Eternal Digital Garden",