feat: add preloadLines configuration. see #28 #138
This file contains 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: Package and Release | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
check: | |
name: 检查并创建版本号 | |
runs-on: ubuntu-latest | |
outputs: | |
created: ${{ steps.create_tag.outputs.created }} | |
steps: | |
- name: 检出代码 | |
uses: actions/checkout@v4 | |
- name: 配置 Node.js | |
uses: actions/setup-node@v4 | |
- name: 获取所有标签 | |
run: | | |
git fetch --prune --unshallow | |
- name: 读取 package.json 版本号 | |
id: package_json | |
run: | | |
version=$(node -p "require('./package.json').version") | |
echo "Package version is: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: 检查是否有重复的版本 tag | |
id: check_version | |
run: | | |
package_version=v${{ steps.package_json.outputs.version }} | |
if git tag -l "$package_version" | grep -q "$package_version"; then | |
echo "::notice::版本 Tag '$package_version' 已存在。" | |
echo "exists=true" >> $GITHUB_OUTPUT | |
fi | |
- name: 创建版本tag | |
id: create_tag | |
if: steps.check_version.outputs.exists != 'true' | |
run: | | |
set -e | |
version_tag=v${{ steps.package_json.outputs.version }} | |
echo "Creating new tag: $version_tag" | |
git tag "$version_tag" | |
git push origin "$version_tag" | |
echo "created=true" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
name: 构建并发版 | |
runs-on: ubuntu-latest | |
needs: check | |
if: needs.check.outputs.created == 'true' | |
permissions: | |
contents: write | |
steps: | |
- name: 检出代码 | |
uses: actions/checkout@v4 | |
- name: 配置 Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: 安装 PNPM | |
uses: pnpm/action-setup@v4 | |
with: | |
version: latest | |
run_install: false | |
- name: 配置 pnpm store 目录 | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: 配置 pnpm 缓存 | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: 安装依赖 | |
run: pnpm i --frozen-lockfile | |
- name: 打包扩展 | |
run: npx vsce package | |
- name: 构建发版 | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: 'v${{needs.check.outputs.version}}' | |
files: '*.vsix' | |
- name: 发布扩展到 VSCODE | |
run: npx vsce publish | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
- name: 发布扩展到 Open VSX | |
run: npx ovsx publish | |
env: | |
OVSX_PAT: ${{ secrets.OVSX_PAT }} |