diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d7e832812..7796848a2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -32,10 +32,29 @@ 从用户角度描述具体变化,以及可能的 breaking change 和其他风险。 --> -- fix(组件名称): 处理问题或特性描述 ... - - [ ] 本条 PR 不需要纳入 Changelog +#### tdesign-miniprogram + + + + +#### tdesign-uniapp + + + + +#### tdesign-uniapp-chat + + + + ### ☑️ 请求合并前的自查清单 ⚠️ 请自检并全部**勾选全部选项**。⚠️ diff --git a/.github/workflows/auto-changelog-callback.yml b/.github/workflows/auto-changelog-callback.yml new file mode 100644 index 000000000..9c402b6f4 --- /dev/null +++ b/.github/workflows/auto-changelog-callback.yml @@ -0,0 +1,31 @@ +name: auto-changelog-callback + +on: + workflow_run: + workflows: + - auto-changelog + types: + - completed + +jobs: + commit-changelog: + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request_review' }} + runs-on: ubuntu-latest + steps: + - name: Download pr id + uses: dawidd6/action-download-artifact@v8 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + run_id: ${{ github.event.workflow_run.id }} + name: pr-id + + - name: Output pr id + id: pr + run: echo "id=$(cat pr-id.txt)" >> $GITHUB_OUTPUT + + - name: auto-changelog + uses: TDesignOteam/flow-pilot-action@develop + with: + token: ${{ secrets.TDESIGN_BOT_TOKEN }} + packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat' + pr_number: ${{ steps.pr.outputs.id }} diff --git a/.github/workflows/auto-changelog.yml b/.github/workflows/auto-changelog.yml new file mode 100644 index 000000000..168fa1014 --- /dev/null +++ b/.github/workflows/auto-changelog.yml @@ -0,0 +1,44 @@ +name: auto-changelog + +on: + pull_request: + types: [opened] + + pull_request_review: + types: [submitted] + + issue_comment: + types: [edited] + +jobs: + changelog: + if: github.event.review.state == 'approved' + runs-on: ubuntu-latest + steps: + - run: echo ${{ github.event.pull_request.number }} > pr-id.txt + + - uses: actions/upload-artifact@v4 + with: + name: pr-id + path: pr-id.txt + retention-days: 5 + + comment-release-changelog: + if: github.event.pull_request && startsWith(github.head_ref, 'release/') + runs-on: ubuntu-latest + steps: + - name: auto-changelog + uses: TDesignOteam/flow-pilot-action@develop + with: + token: ${{ secrets.TDESIGN_BOT_TOKEN }} + packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat' + + commit-changelog: + if: github.event.issue.pull_request + runs-on: ubuntu-latest + steps: + - name: auto-changelog + uses: TDesignOteam/flow-pilot-action@develop + with: + token: ${{ secrets.TDESIGN_BOT_TOKEN }} + packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat' diff --git a/.github/workflows/auto-publish.yml b/.github/workflows/auto-publish.yml new file mode 100644 index 000000000..ede749365 --- /dev/null +++ b/.github/workflows/auto-publish.yml @@ -0,0 +1,66 @@ +name: auto-publish + +on: + release: + types: [created] + +jobs: + publish-official-website: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: main + fetch-depth: 0 + submodules: recursive + token: ${{ secrets.TDESIGN_BOT_TOKEN }} + + - name: update official website + run: | + git config --local user.email "tdesign@tencent.com" + git config --local user.name "tdesign-bot" + git status + git fetch origin + git merge origin/develop + git push origin main + + publish-miniprogram: + if: startsWith(github.event.release.tag_name,'tdesign-miniprogram') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v6 + with: + node-version: 18 + + - run: pnpm install + + - run: pnpm build + + - name: extract version + id: version + run: | + const tagName = '${{ github.event.release.tag_name }}' + const lastIndex = tagName.lastIndexOf('@'); + const version = tagName.slice(lastIndex + 1); + echo "version=$version" >> $GITHUB_OUTPUT + shell: bash + + - name: release miniprogram + uses: LeeJim/setup-miniprogram@main + with: + project_type: miniProgram + action_type: upload + project_path: ./_example + version: ${{ steps.version.outputs.version }} + es6: true + es7: true + minify: true + env: + MINI_APP_ID: ${{ secrets.TDESIGN_APP_ID }} + MINI_APP_PRIVATE_KEY: ${{ secrets.TDESIGN_MINI_KEY }} diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index cf1d33cd7..43495fa69 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -1,95 +1,39 @@ -name: Auto Release +name: auto-release on: pull_request: - branches: [develop] - types: [opened, synchronize, reopened, closed] - paths: - - 'packages/tdesign-miniprogram/package.json' - issue_comment: - types: [edited] + types: [closed] + +permissions: + contents: read + id-token: write jobs: - generator: + publish: + if: github.event.pull_request.merged && startsWith(github.head_ref, 'release/') runs-on: ubuntu-latest - if: > - github.event_name == 'pull_request' && - github.event.pull_request.merged == false && - startsWith(github.head_ref, 'release/') steps: - - run: echo "The head of this PR starts with 'release/'" - - uses: actions/checkout@v3 - - name: Extract version - id: version - run: | - echo "version=$(node -p 'require("./packages/tdesign-miniprogram/package.json").version')" >> $GITHUB_OUTPUT - - uses: TDesignOteam/tdesign-changelog-action@main - id: changelog + - uses: actions/checkout@v4 with: - tag: ${{ steps.version.outputs.version }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Add comment - uses: peter-evans/create-or-update-comment@v1 + submodules: recursive + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 with: - issue-number: ${{ github.event.pull_request.number }} - body: | - ${{ steps.changelog.outputs.changelog }} - comment_add_log: - runs-on: ubuntu-latest - if: > - github.event_name == 'issue_comment' - && github.event.issue.pull_request - && github.event.sender.login == github.event.issue.user.login - && startsWith(github.event.comment.body, '## 🌈 ') - steps: - - id: comment - shell: bash - run: | - result=$(curl ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}") - headrefreg='"ref": "(release/[[:digit:]]{1,2}\.[[:digit:]]{1,2}\.[[:digit:]]{1,2})",' - if [[ $result =~ $headrefreg ]] - then - echo "属于 release pr 的 comment ${BASH_REMATCH[1]}" - else - echo "不属于 release pr 的 comment" && exit 1 - fi - echo "branch=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT - # zsh $match[1] - - uses: actions/checkout@v3 + node-version: 18 + + - run: pnpm install + + - run: pnpm build + + - run: pnpm run uniapp build:npm + + - uses: actions/setup-node@v4 with: - ref: ${{ steps.comment.outputs.branch }} - - name: Commit and push if needed - env: - BODY: ${{ github.event.comment.body }} - run: | - txt=$(cat packages/tdesign-miniprogram/CHANGELOG.md) - echo "${txt%%##*}$BODY${txt##*---}" > packages/tdesign-miniprogram/CHANGELOG.md - git add . - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git commit -m "chore: changelog's changes" - git push - echo "💾 pushed changelog's changes" - merge_tag: - runs-on: ubuntu-latest - if: > - github.event_name == 'pull_request' && - github.event.pull_request.merged == true && - startsWith(github.head_ref, 'release/') - steps: - - uses: actions/checkout@v3 + node-version: 24 + + - uses: TDesignOteam/flow-pilot-action@develop with: - ref: develop - token: ${{ secrets.PERSONAL_TOKEN }} - - name: tag and push if needed - run: | - data=$(cat packages/tdesign-miniprogram/package.json) - re="\"version\": \"([^\"]*)\"" - [[ $data =~ $re ]] - echo "${BASH_REMATCH[1]}" - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git tag ${BASH_REMATCH[1]} - git push origin ${BASH_REMATCH[1]} - echo "pushed tag ${BASH_REMATCH[1]}" + token: ${{ secrets.TDESIGN_BOT_TOKEN }} + packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat' diff --git a/.github/workflows/tag-push.yml b/.github/workflows/tag-push.yml deleted file mode 100644 index 87a1a3d3f..000000000 --- a/.github/workflows/tag-push.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: TAG_PUSH - -on: create - -jobs: - TAG_PUSH: - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - if: github.event.ref_type == 'tag' - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/install-dep - - run: pnpm build - shell: bash - - name: release miniprogram - uses: LeeJim/setup-miniprogram@main - with: - project_type: miniProgram - action_type: upload - project_path: ./_example - version: ${{ github.ref_name }} - es6: true - es7: true - minify: true - env: - MINI_APP_ID: ${{ secrets.TDESIGN_APP_ID }} - MINI_APP_PRIVATE_KEY: ${{ secrets.TDESIGN_MINI_KEY }} - - - run: sudo npm install -g npm@latest - - - id: publish - name: publish NPM - uses: JS-DevTools/npm-publish@v4 - with: - package: packages/tdesign-miniprogram - tag: ${{ contains(github.ref_name, 'beta') && 'beta' || 'latest' }} - - if: steps.publish.outputs.type != 'none' - run: | - echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" - UPDATE_OFFICIAL_WEBSITE: - runs-on: ubuntu-latest - if: github.event.ref_type == 'tag' - steps: - - uses: actions/checkout@v3 - with: - ref: main - fetch-depth: 0 - token: ${{ secrets.PERSONAL_TOKEN }} - submodules: recursive - - name: update official website - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git status - git fetch origin - git merge origin/develop -X theirs - git push origin main