Skip to content

chore: 调整发布流程 #103

chore: 调整发布流程

chore: 调整发布流程 #103

Workflow file for this run

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Publish orca-pocket
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'packages/*/package.json'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/publish.yml'
jobs:
replace-package-json-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: install dependencies
run: |
npm i pnpm -g
pnpm i --no-frozen-lockfile
- name: publish
id: changesets
uses: changesets/action@v1
with:
publish: npm run pub:only
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Format publish log
id: publish_log
uses: actions/github-script@v4
if: steps.changesets.outputs.published == 'true'
with:
script: |
console.log(`::set-output name=log::${
${{ steps.changesets.outputs.publishedPackages }}.map(({name,version}) => ' - '+name+'@'+version).join('\n')
}`)
- name: Dingtalk Notify
uses: zcong1993/actions-ding@master
if: steps.changesets.outputs.published == 'true'
with:
dingToken: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
body: |
{
"msgtype": "markdown",
"markdown": {
"title":"orca-fe 发布通知",
"text": "### @orca-fe/pocket\n\n流水线结束,以下模块已发布:\n\n${{ steps.changelog.outputs.changes }}"
},
"at": {
"isAtAll": false
}
}
- name: Dingtalk Notify Error
uses: zcong1993/actions-ding@master
if: steps.changesets.outputs.published == 'false' || steps.changesets.outputs.hasChangesets == 'false'
with:
dingToken: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
body: |
{
"msgtype": "markdown",
"markdown": {
"title":"orca-fe 未发布通知",
"text": "### @orca-fe/pocket\n\n流水线结束,未发布模块。"
}
}