Skip to content

修改release.yml

修改release.yml #5

Workflow file for this run

# 工作流名称
name: .NET Compact 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
- 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 false -p:PublishSingleFile=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
# 修正了参数名,并设置为 error,因为此时如果一个文件都找不到,说明打包出错了
if-no-files-found: error
# 发布任务 (保持不变)
release:
needs: build
runs-on: ubuntu-latest
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/**/*/*.*