Repository navigation
137 lines (119 loc) · 5.29 KB
/
Copy pathrelease.yml
File metadata and controls
137 lines (119 loc) · 5.29 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Build and Release x86 x64 7zips
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Semantic version tag to create release for (vX.Y.Z). !Remember to bump in OneColumnEncoder.csproj!'
required: true
type: string
default: 'v1.0.0'
push:
tags:
- 'v*'
jobs:
build:
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine final tag name
shell: pwsh
run: |
$tag = ""
if ("${{ github.event_name }}" -eq "push" -and "${{ github.ref }}" -like "refs/tags/*") {
$tag = "${{ github.ref_name }}"
} elseif ("${{ github.event_name }}" -eq "workflow_dispatch") {
$inputTag = "${{ inputs.tag_name }}".Trim()
$tag = $inputTag
}
if ($tag -notmatch '^v\d+\.\d+\.\d+$') {
Write-Error "Release tag must use vX.Y.Z format, received: '$tag'."
exit 1
}
echo "FINAL_TAG=$tag" >> $env:GITHUB_ENV
echo "RELEASE_VERSION=$($tag.Substring(1))" >> $env:GITHUB_ENV
Write-Host "[SUCCESS] Final tag: $tag"
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
- name: Validate project version
shell: pwsh
run: |
[xml]$project = Get-Content .\OneColumnEncoder.csproj
$projectVersion = [string]$project.Project.PropertyGroup.Version
if ($projectVersion -ne "${{ env.RELEASE_VERSION }}") {
Write-Error "Project version '$projectVersion' does not match release tag '${{ env.FINAL_TAG }}'."
exit 1
}
- name: Publish x86
run: |
dotnet publish OneColumnEncoder.csproj `
--configuration Release `
--runtime win-x86 `
--self-contained true `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
--output ./publish/x86
- name: Publish x64
run: |
dotnet publish OneColumnEncoder.csproj `
--configuration Release `
--runtime win-x64 `
--self-contained true `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
--output ./publish/x64
- name: Copy extra tools
shell: pwsh
run: |
if (Test-Path ".\cicd") {
# 编码器
Copy-Item -Path ".\cicd\x64-upstreams-encoders.7z" -Destination ".\publish\x64\" -Force
Copy-Item -Path ".\cicd\x86-upstreams-encoders.7z" -Destination ".\publish\x86\" -Force
# 单图画质跑分算法 + 附带的滤镜:默认放进 1cenc 配置目录
Copy-Item -Path ".\cicd\1cenc" -Destination ".\publish\x64\" -Recurse -Force
Write-Host "✅ Tools copied to both publish folders."
} else {
throw "[MISSING] No 'cicd' folder found, cannot continue."
}
- name: Prepare Release Info (commit number, SHA, notes)
shell: pwsh
run: |
$count = git rev-list --count HEAD
$sha = git rev-parse --short=8 HEAD
$title = "1cenc v${{ env.RELEASE_VERSION }}"
$body = "**Commit $count $sha**`n`n"
$body += "Follow this tutorial to get tools (pipe upstream / filtering tools & video encoders) tailored for your use case | 你可以根据此教程来获取合适的工具(管道上游程序/滤镜工具与视频编码器):`n"
$body += "- [Encoding Tools Download Tutorial | 编码工具下载教程](https://github.com/iAvoe/encoding-tools-download-tutorial)`n`n"
$body += "Or, TLDR; and use tools provided in downloaded package (not recommended but it works) | 或者着急要用的话,也可以无视上述教程,下载并直接使用附带的工具(不推荐但可以)"
$body += "`n"
$body += "`n"
$body += "> [!NOTE]`n"
$body += "> x86 release (32bit) has limited integration since many of tools and libraries lacks this support, provided as-is | x86 发布版本缺少多种工具集成,大多因为 32bit 编译缺少支持,或者依赖的静态库不支持 32bit 且修正不了,请将就使用"
$body += "`n"
echo "RELEASE_TITLE=$title" >> $env:GITHUB_ENV
$body | Out-File -FilePath .\release-notes.md -Encoding utf8
- name: Pack x86
run: 7z a -t7z -mx9 1cenc-v${{ env.RELEASE_VERSION }}-win-x86.7z .\publish\x86\*
- name: Pack x64
run: 7z a -t7z -mx9 1cenc-v${{ env.RELEASE_VERSION }}-win-x64.7z .\publish\x64\*
- name: Delete existing release (if any)
shell: pwsh
run: |
gh release delete "${{ env.FINAL_TAG }}" -y || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release and Upload Assets
shell: pwsh
run: |
gh release create "${{ env.FINAL_TAG }}" `
--title "${{ env.RELEASE_TITLE }}" `
--notes-file .\release-notes.md `
1cenc-v${{ env.RELEASE_VERSION }}-win-x86.7z 1cenc-v${{ env.RELEASE_VERSION }}-win-x64.7z
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}