fix error #6
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 工作流名称 | |
| name: .NET Release Publisher | |
| # 触发条件 | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+*' | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| # 【修改点 1】改回独立部署并开启代码裁剪优化 | |
| - name: Publish application | |
| run: dotnet publish ./Html-Converter.csproj -c Release -r ${{ matrix.os == 'windows-latest' && 'win-x64' || (matrix.os == 'ubuntu-latest' && 'linux-x64' || 'osx-x64') }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:InvariantGlobalization=true | |
| - name: Package artifacts | |
| run: | | |
| ARTIFACT_NAME="Html-Converter-${{ matrix.os == 'windows-latest' && 'win-x64' || (matrix.os == 'ubuntu-latest' && 'linux-x64' || 'osx-x64') }}" | |
| PUBLISH_DIR="./bin/Release/net8.0/${{ matrix.os == 'windows-latest' && 'win-x64' || (matrix.os == 'ubuntu-latest' && 'linux-x64' || 'osx-x64') }}/publish" | |
| if [ "${{ matrix.os }}" == "windows-latest" ]; then | |
| 7z a "${ARTIFACT_NAME}.zip" "${PUBLISH_DIR}/Html-Converter.exe" | |
| else | |
| tar -czvf "${ARTIFACT_NAME}.tar.gz" -C "${PUBLISH_DIR}" "Html-Converter" | |
| fi | |
| shell: bash | |
| - name: Upload Final Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-artifact-${{ matrix.os }} | |
| path: | | |
| Html-Converter-*.zip | |
| Html-Converter-*.tar.gz | |
| if-no-files-found: error | |
| # 发布任务 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| # 【修改点 2】为发布任务授予写入权限 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: artifacts/**/*/*.* |