to-publish-npm #8
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: Npm publish | |
# on: | |
# push: | |
# tags: | |
# - "v*" # 这段的意思是仅在出现名为 v 字符开头的tag时,触发此任务,如v1.2.1 | |
on: | |
repository_dispatch: | |
types: [to-publish-npm] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Set timezone to Asia/Shanghai | |
uses: szenius/[email protected] | |
with: | |
# 设置执行环境的时区为 Linux 上海时区 | |
timezoneLinux: "Asia/Shanghai" | |
- name: Echo current time | |
run: timedatectl | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.11.1 | |
- name: Install pnpm | |
run: | | |
npm install -g pnpm | |
# pnpm config set store-dir $(pwd)/.pnpm-store | |
# pnpm config set recursive-optional true | |
- name: Install Dependence | |
run: pnpm i | |
- name: Build dist | |
run: pnpm run build | |
- name: Start publish | |
run: npm publish # 如果发布之前需要构建,可添加prepublishOnly的生命周期脚本 | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} # 上面在Github Secrets中设置的密钥 |