Skip to content

🐎 ci: add stylelint #16

🐎 ci: add stylelint

🐎 ci: add stylelint #16

Workflow file for this run

name: 构建/部署/发布/NPM/tag/Release
on:
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Node.js 版本
uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: 安装 pnpm
run: npm install -g pnpm
- name: 删除 node_modules 目录
run: rm -rf node_modules
- name: 安装依赖
run: pnpm i
- name: 项目构建
run: pnpm run build
- name: 项目部署
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
branch: gh-pages
folder: dist
- name: 获取版本号
uses: tyankatsu0105/read-package-version-actions@v1
id: package-version
# 暂存 contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') 结果
- name: 判断 tag 是否存在
uses: mukunku/tag-exists-action@v1.6.0
id: check-tag
with:
tag: v${{ steps.package-version.outputs.version }}
- name: 创建 tag
if: steps.check-tag.outputs.exists == 'false'
# run: git tag v${{ steps.package-version.outputs.version }} && git push --tags
uses: rickstaa/action-create-tag@v1
id: "tag_create"
with:
tag: v${{ steps.package-version.outputs.version }}
tag_exists_error: false
- name: 发布 Release
if: steps.check-tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.package-version.outputs.version }}
tag_name: v${{ steps.package-version.outputs.version }}
- name: 发布到 NPM
if: steps.check-tag.outputs.exists == 'false'
# 根据 version 判断是否需要加 --tag [alpha|beta]
run: npm publish --tag ${{ contains(steps.package-version.outputs.version, 'alpha') && 'alpha' || contains(steps.package-version.outputs.version, 'beta') && 'beta' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}