Skip to content

Commit

Permalink
6
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Apr 2, 2024
1 parent b9df423 commit a6a2288
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
65 changes: 36 additions & 29 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a6a2288

Please sign in to comment.