feat: 修复CI没有发布版本问题 #2
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: Node Project CI | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
# otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
persist-credentials: false | |
# otherwise, there would be errors pushing refs to the destination repository. | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
# 选择要使用的 pnpm 版本 | |
version: 7 | |
# 使用 pnpm 安装依赖 | |
run_install: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
# 选择要使用的 node 版本 | |
node-version: 16.14.2 | |
# 缓存 pnpm 依赖 | |
cache: pnpm | |
# 运行构建脚本 | |
- name: Build tasks | |
run: npm run build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 保存一些信息 | |
- name: Set info | |
run: | | |
eaho "version=node -p \"require('./package.json').version\"" >> $GITHUB_ENV | |
eaho "name=node -p \"require('./package.json').name\"" >> $GITHUB_ENV | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: ./dist/index.js | |
env: | |
name: ${{env.name}}:${{env.version}} | |
# - name: Deploy to GitHub Pages | |
# uses: crazy-max/ghaction-github-pages@v4 | |
# with: | |
# target_branch: gh-pages | |
# build_dir: dist | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |