From 18cfbc44321032028703bd2352834dbd0c889f86 Mon Sep 17 00:00:00 2001 From: OverLoad Date: Sat, 28 Jun 2025 22:03:07 +0800 Subject: [PATCH] fix artifact name --- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 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..543f4f6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + release: + types: [created] + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - name: Build release binary + run: cargo build --verbose --release + - name: Package binary + shell: pwsh + run: | + New-Item -ItemType Directory -Force dist + Copy-Item target/release/EasyProxy.exe dist/ + Compress-Archive -Path dist/EasyProxy.exe -DestinationPath release.zip + - name: Upload Release + uses: actions/upload-artifact@v4 + with: + name: EasyProxy + path: release.zip + retention-days: 30 + - name: Get existing Release upload URL + id: get_release + uses: actions/github-script@v6 + with: + script: | + const tag = context.ref.startsWith('refs/tags/') ? context.ref.substring('refs/tags/'.length) : context.ref; + core.info(`Using tag: ${tag}`); + const release = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag: tag + }); + const uploadUrl = release.data.upload_url; // 不要去掉 {?name,label} + core.info(`Found release with upload_url: ${uploadUrl}`); + return uploadUrl; + - name: Debug GITHUB_TOKEN + shell: pwsh + run: | + if ($env:GITHUB_TOKEN) { + Write-Host 'GITHUB_TOKEN is defined.' + } else { + Write-Host 'GITHUB_TOKEN is NOT defined.' + } + - name: Create Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + release.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}