Skip to content

Commit c2ca512

Browse files
committed
ci: 在版本标签工作流中增加 GitHub Release 创建和 VSIX 上传
- 在版本更新时增加构建 VSIX 扩展包的步骤 - 实现从 CHANGELOG.md 中自动提取当前版本的更新日志 - 配置使用 GitHub CLI 创建 Release 并上传生成的 VSIX 文件
1 parent 55d2a42 commit c2ca512

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/create-version-tag.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
echo "exists=false" >> "${GITHUB_OUTPUT}"
7474
fi
7575
76+
7677
- name: Create and push tag
7778
if: steps.version.outputs.changed == 'true' && steps.tag_exists.outputs.exists == 'false'
7879
shell: bash
@@ -84,6 +85,44 @@ jobs:
8485
git tag -a "${TAG_NAME}" -m "Release ${TAG_NAME}"
8586
git push origin "${TAG_NAME}"
8687
88+
- name: Build VSIX
89+
if: steps.version.outputs.changed == 'true' && steps.tag_exists.outputs.exists == 'false'
90+
shell: bash
91+
run: |
92+
set -euo pipefail
93+
npm ci
94+
npm run package:vsix
95+
96+
- name: Extract changelog for release
97+
id: changelog
98+
if: steps.version.outputs.changed == 'true' && steps.tag_exists.outputs.exists == 'false'
99+
shell: bash
100+
run: |
101+
set -euo pipefail
102+
VERSION="${{ steps.version.outputs.current }}"
103+
# Escape dots for regex matching
104+
ESCAPED_VERSION="${VERSION//\./\\.}"
105+
# Extract lines between "## [VERSION]" and next "## ["
106+
awk "/^## \[${ESCAPED_VERSION}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md > /tmp/release_body.md
107+
echo "file=/tmp/release_body.md" >> "${GITHUB_OUTPUT}"
108+
109+
- name: Create Release and upload VSIX
110+
if: steps.version.outputs.changed == 'true' && steps.tag_exists.outputs.exists == 'false'
111+
shell: bash
112+
env:
113+
GH_TOKEN: ${{ github.token }}
114+
run: |
115+
set -euo pipefail
116+
VSIX_FILE="$(ls *.vsix | head -1)"
117+
if [[ -z "${VSIX_FILE}" ]]; then
118+
echo "No .vsix file found after build"
119+
exit 1
120+
fi
121+
gh release create "${{ steps.version.outputs.tag }}" \
122+
--title "Release ${{ steps.version.outputs.tag }}" \
123+
--notes-file "${{ steps.changelog.outputs.file }}" \
124+
"${VSIX_FILE}"
125+
87126
- name: Summary
88127
shell: bash
89128
run: |

0 commit comments

Comments
 (0)