chore(release): bump version to 1.6.0 #23
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-release: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Setup NuGet | |
| uses: nuget/setup-nuget@v2 | |
| - name: Restore NuGet packages | |
| run: nuget restore LumiShift.sln | |
| - name: Build Release | |
| run: msbuild LumiShift.sln /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal | |
| - name: Stage artifacts | |
| shell: pwsh | |
| run: | | |
| $src = "LumiShift/bin/Release" | |
| if (-not (Test-Path $src)) { | |
| Write-Error "Build output not found: $src" | |
| exit 1 | |
| } | |
| $staging = "staging" | |
| New-Item -ItemType Directory -Force -Path $staging | Out-Null | |
| # 主程序 | |
| $exe = Get-ChildItem -Path $src -Filter "LumiShift.exe" | Select-Object -First 1 | |
| if (-not $exe) { Write-Error "LumiShift.exe not found"; exit 1 } | |
| Copy-Item $exe.FullName "$staging/LumiShift.exe" | |
| # 配置文件(运行时需要) | |
| $config = Get-ChildItem -Path $src -Filter "LumiShift.exe.config" | Select-Object -First 1 | |
| if ($config) { Copy-Item $config.FullName "$staging/LumiShift.exe.config" } | |
| Write-Host "=== Staged files ===" | |
| Get-ChildItem $staging | ForEach-Object { Write-Host $_.Name } | |
| - name: Extract version from tag | |
| id: version | |
| shell: bash | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| VERSION="${TAG#v}" | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Extract changelog for release | |
| id: changelog | |
| shell: pwsh | |
| run: | | |
| $version = "${{ steps.version.outputs.version }}" | |
| $changelog = Get-Content -Raw CHANGELOG.md | |
| # 匹配 ## [版本号] 到下一个 ## [ 或 --- | |
| $pattern = "## \[$([regex]::Escape($version))\][\s\S]*?(?=\n## \[|\n---|\Z)" | |
| $match = [regex]::Match($changelog, $pattern) | |
| if ($match.Success) { | |
| $body = $match.Value.Trim() | |
| $body | Set-Content -Path changelog_body.txt -Encoding UTF8 | |
| Write-Host "Extracted changelog for v$version" | |
| } else { | |
| Write-Host "::warning::Changelog for v$version not found, using tag as body" | |
| "Release ${{ steps.version.outputs.tag }}" | Set-Content -Path changelog_body.txt -Encoding UTF8 | |
| } | |
| - name: Delete existing release (if any) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| RELEASE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
| "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/$TAG") | |
| RELEASE_ID=$(echo "$RELEASE" | jq -r '.id // empty') | |
| if [ -n "$RELEASE_ID" ] && [ "$RELEASE_ID" != "null" ]; then | |
| echo "Deleting existing release $RELEASE_ID for tag $TAG" | |
| curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
| "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/$RELEASE_ID" | |
| else | |
| echo "No existing release found for tag $TAG" | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: LumiShift ${{ steps.version.outputs.tag }} | |
| draft: false | |
| body_path: changelog_body.txt | |
| files: | | |
| staging/LumiShift.exe | |
| staging/LumiShift.exe.config |