Skip to content

my-event

my-event #33

name: Release
on:
push:
branches: [ main ]
paths:
- 'package*.json'
repository_dispatch:
types: [my-event]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # 先检出代码
- name: 初始化node环境
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # 如果不配置将影响publish
- name: Set up Git
run: |
git config --global user.name "xsf0105"
git config --global user.email "allan91coder@gmail.com"
- run: npm install
- run: npm run release:patch # 发布新版本
- name: git add
run: |
git add .
git commit -m "feat: update package.json version"
git push
- run: npm run build
- name: publish # 向npm publish 代码 请遵循npm规范.
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} # 该token是 npm的token 获取npm token请查看 步骤2 的创建 npm token 和 将npm token 放入github的 secrets下
run: npm publish
# 到这如果全部成功,那么我们就成功的将代码发布到了npm
# 下面主要是创建 github 的release
# 需要手动修改 package.json 版本
# 使用 tyankatsu0105/read-package-version-actions@v1 工具来读取对应的package.json 数据
- name: Read package.json
uses: tyankatsu0105/read-package-version-actions@v1
id: package-version
# 关于创建 release 的更多参数,可以查看 actions/create-release@v1
- name: Create Release for Tag
id: release_tag
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GIT_ACTION }} # 这块需要用到 github的token,因为需要对分之进行代码推送
with:
tag_name: v${{ steps.package-version.outputs.version }}
release_name: Release v${{ steps.package-version.outputs.version }}
prerelease: false # 是否为预发布版本
# body: |
# 请点击查看 [更新日志]().