-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (117 loc) · 4.1 KB
/
release.yml
File metadata and controls
117 lines (117 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Build & Release (x64+arm64, FD + SelfContained SingleFile)
on:
workflow_dispatch:
permissions:
contents: write
jobs:
precheck:
name: Read version & check release exists
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Read AssemblyVersion from csproj
id: ver
shell: pwsh
run: |
$csproj = "src/FileWatcherForEmby.csproj"
if (!(Test-Path $csproj)) { throw "Not found: $csproj" }
[xml]$xml = Get-Content $csproj
$version = @($xml.Project.PropertyGroup.AssemblyVersion | Where-Object { $_ -and $_.Trim() -ne "" })[0]
if (-not $version) { throw "AssemblyVersion not found in $csproj" }
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
Write-Host "AssemblyVersion=$version"
- name: Fail if GitHub Release already exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.ver.outputs.version }}
run: |
set -euo pipefail
if gh api "/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" >/dev/null 2>&1; then
echo "Release with tag '${TAG}' already exists. Abort."
exit 1
fi
echo "Release tag '${TAG}' does not exist. Continue."
build:
name: Build zips (${{ matrix.rid }} / ${{ matrix.flavor }})
needs: precheck
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
rid: [win-x64, win-arm64]
flavor: [fd, sc-singlefile]
steps:
- uses: actions/checkout@v4
- name: Setup .NET (net10)
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
# 若你使用 net10 预览版 SDK,可启用:
# include-prerelease: true
- name: Restore
run: dotnet restore src/FileWatcherForEmby.csproj
- name: Publish
shell: pwsh
run: |
$rid = "${{ matrix.rid }}"
$flavor = "${{ matrix.flavor }}"
$outDir = "out\$flavor-$rid"
if ($flavor -eq "fd") {
dotnet publish src/FileWatcherForEmby.csproj `
-c Release -f net10.0 -r $rid `
--self-contained false `
-o $outDir
} else {
dotnet publish src/FileWatcherForEmby.csproj `
-c Release -f net10.0 -r $rid `
--self-contained true `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
-o $outDir
}
- name: Delete PDB files
shell: pwsh
run: |
Get-ChildItem -Path out -Recurse -Filter *.pdb | Remove-Item -Force
- name: Create zip
shell: pwsh
env:
TAG: ${{ needs.precheck.outputs.version }}
run: |
$rid = "${{ matrix.rid }}"
$flavor = "${{ matrix.flavor }}"
$src = "out\$flavor-$rid\*"
$zipName = if ($flavor -eq "fd") {
"FileWatcherForEmby-$env:TAG-$rid-framework-dependent.zip"
} else {
"FileWatcherForEmby-$env:TAG-$rid-self-contained-singlefile.zip"
}
if (Test-Path $zipName) { Remove-Item $zipName -Force }
Compress-Archive -Path $src -DestinationPath $zipName
- name: Upload zip artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.flavor }}-${{ matrix.rid }}
path: |
FileWatcherForEmby-*.zip
release:
name: Create GitHub Release
needs: [precheck, build]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Create Release and upload assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.precheck.outputs.version }}
run: |
set -euo pipefail
gh release create "${TAG}" dist/**/FileWatcherForEmby-*.zip \
--repo "${GITHUB_REPOSITORY}" \
--title "${TAG}" \
--notes "Automated release ${TAG}"