diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f8efa16 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release + +on: + push: + branches: [main] + +permissions: + contents: write + issues: write + pull-requests: write + packages: write + id-token: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: 签出代码 + uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: 安装 nodejs + uses: actions/setup-node@v2.5.2 + with: + node-version: "20.8.1" + + - name: 构建 web app + working-directory: ./packages/web + run: | + pnpm install --no-frozen-lockfile + pnpm run build + cp -r dist/* ../server/libs/web-dist/ + + - name: 发布 core npm 包 + env: + GITHUB_TOKEN: ${{ secrets.PUBLISH_GH_TOKEN }} + NPM_TOKEN: ${{ secrets.PUBLISH_NPM_TOKEN }} + run: npx semantic-release + working-directory: packages/core + + - name: 发布 server npm 包 + env: + GITHUB_TOKEN: ${{ secrets.PUBLISH_GH_TOKEN }} + NPM_TOKEN: ${{ secrets.PUBLISH_NPM_TOKEN }} + run: npx semantic-release + working-directory: packages/server diff --git a/packages/core/.releaserc.js b/packages/core/.releaserc.js index 935c518..bacc126 100644 --- a/packages/core/.releaserc.js +++ b/packages/core/.releaserc.js @@ -1,5 +1,5 @@ module.exports = { - branches: ["release"], // 指定在哪个分支下要执行发布操作 + branches: ["main"], // 指定在哪个分支下要执行发布操作 plugins: [ "@semantic-release/commit-analyzer", // 解析 commit 信息,默认就是 Angular 规范 "@semantic-release/release-notes-generator", diff --git a/packages/server/.releaserc.js b/packages/server/.releaserc.js index deb9d71..d35bf40 100644 --- a/packages/server/.releaserc.js +++ b/packages/server/.releaserc.js @@ -1,12 +1,12 @@ module.exports = { - branches: ["release"], // 指定在哪个分支下要执行发布操作 + branches: ["main"], // 指定在哪个分支下要执行发布操作 plugins: [ "@semantic-release/commit-analyzer", // 解析 commit 信息,默认就是 Angular 规范 "@semantic-release/release-notes-generator", [ "@semantic-release/changelog", { - changelogFile: "CHANGELOG.md", // 把发布日志写入该文件 + changelogFile: "../../CHANGELOG.md", // 把发布日志写入该文件 }, ], "@semantic-release/npm", // 发布到NPM @@ -14,7 +14,7 @@ module.exports = { [ "@semantic-release/git", { - assets: ["CHANGELOG.md", "package.json"], // 前面说到日志记录和版本好是新增修改的,需要 push 回 Git + assets: ["../../CHANGELOG.md", "../../package.json"], // 前面说到日志记录和版本好是新增修改的,需要 push 回 Git }, ], ],