Skip to content

init

init #1

name: Release
permissions:
contents: write
on:
push:
tags:
- "v*"
jobs:
build:
name: 构建Windows可执行文件
runs-on: windows-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置Python环境
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"
- name: 安装依赖
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install
- name: 获取版本号
id: get_version
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: 准备Release说明
id: release_notes
shell: pwsh
run: |
$version = "${{ env.VERSION }}"
$header = "AI代码上下文助手 v$version 发布"
$defaultNotes = "* 暂无此版本的详细更新说明"
$footer = "## 下载`n* 点击下方附件下载应用程序"
# 默认版本说明
$versionNotes = $defaultNotes
# 检查CHANGELOG.md是否存在
if (Test-Path "CHANGELOG.md") {
$content = Get-Content "CHANGELOG.md"
$versionHeader = "## v${version}"
$captureLines = $false
$capturedContent = @()
# 逐行处理CHANGELOG
foreach ($line in $content) {
# 版本匹配开始
if ($line -match "^$versionHeader($| -)") {
$captureLines = $true
continue
}
# 下一版本标记,停止捕获
elseif ($line -match "^## v" -and $captureLines) {
$captureLines = $false
break
}
# 捕获当前版本内容
elseif ($captureLines -and $line.Trim() -ne "") {
# 转换破折号列表为星号列表
if ($line -match "^- ") {
$line = $line -replace "^- ", "* "
}
$capturedContent += $line
}
}
# 如果找到了版本内容,使用它
if ($capturedContent.Count -gt 0) {
$versionNotes = $capturedContent -join "`n"
}
}
# 创建完整的Release说明
$releaseContent = "$header`n## 更新内容`n$versionNotes`n$footer"
# 保存到文件
$releaseContent | Out-File -FilePath "RELEASE.md" -Encoding utf8
- name: 构建可执行文件
env:
PYTHONIOENCODING: utf-8
run: poetry run cxfreeze build
- name: 创建ZIP压缩包
run: |
Compress-Archive -Path build/exe.win-*/* -DestinationPath AICodeContextHelper_v${{ env.VERSION }}.zip
- name: 创建Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: AI代码上下文助手 v${{ env.VERSION }}
body_path: RELEASE.md
draft: false
prerelease: false
files: |
AICodeContextHelper_v${{ env.VERSION }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}