Release #92
Workflow file for this run
This file contains hidden or 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: Release | |
| on: | |
| push: | |
| tags: | |
| - v* | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., v2.0.0-beta.1)' | |
| required: true | |
| type: string | |
| webui_tag: | |
| description: '可选:捆绑的 WebUI 仓库 tag(默认取当前 main 上可达的最新 v* tag)' | |
| required: false | |
| default: '' | |
| type: string | |
| jobs: | |
| build-webui-dist: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| webui_console_version: ${{ steps.webui_ref.outputs.console_version }} | |
| webui_git_ref: ${{ steps.webui_ref.outputs.resolved_ref }} | |
| steps: | |
| - name: Checkout WebUI repo | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: PallasBot/Pallas-Bot-WebUI | |
| ref: main | |
| path: pallas-webui | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Resolve WebUI release tag | |
| id: webui_ref | |
| working-directory: pallas-webui | |
| env: | |
| PIN_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.webui_tag || '' }} | |
| run: | | |
| set -euo pipefail | |
| git fetch origin --tags --force | |
| if [ -n "${PIN_TAG}" ]; then | |
| git checkout "${PIN_TAG}" | |
| echo "console_version=${PIN_TAG}" >> "$GITHUB_OUTPUT" | |
| echo "resolved_ref=${PIN_TAG}" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| TAG=$(git tag -l 'v*' --merged HEAD --sort=-version:refname | head -n1) | |
| if [ -z "${TAG}" ]; then | |
| TAG=$(git tag -l 'v*' --sort=-version:refname | head -n1) | |
| fi | |
| if [ -n "${TAG}" ]; then | |
| git checkout "${TAG}" | |
| echo "console_version=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "resolved_ref=${TAG}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "::warning::WebUI 仓库无 v* tag,使用 main;console 版本取自 package.json" | |
| VER=$(node -p "require('./package.json').version") | |
| echo "console_version=${VER}" >> "$GITHUB_OUTPUT" | |
| echo "resolved_ref=main" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: pallas-webui/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: pallas-webui | |
| # console-version.json:version = 上游 WebUI 发版 tag(或手动 PIN / 无 tag 时 package.json)。 | |
| - name: Build WebUI | |
| working-directory: pallas-webui | |
| env: | |
| CONSOLE_VERSION: ${{ steps.webui_ref.outputs.console_version }} | |
| run: | | |
| export GIT_COMMIT="$(git rev-parse HEAD)" | |
| export BUILD_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | |
| npm run build:ci | |
| # zip 根目录为 public/,在 Bot 侧解压到 data/pallas_webui 即得到 public/index.html(与插件默认路径一致)。 | |
| - name: Pack dist artifact | |
| run: | | |
| mkdir -p webui-zip-root/public | |
| cp -a pallas-webui/dist/. webui-zip-root/public/ | |
| (cd webui-zip-root && zip -r ../dist.zip public) | |
| - name: Upload WebUI artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: webui-dist-zip | |
| path: dist.zip | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: build-webui-dist | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| # 生成详细的变更日志 | |
| if git describe --tags --abbrev=0 HEAD~1 >/dev/null 2>&1; then | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1) | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| # 按类型分组显示提交 | |
| echo "### 🚀 新功能" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"* %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="^feat" >> $GITHUB_OUTPUT || echo "无" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### 🐛 错误修复" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"* %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="^fix" >> $GITHUB_OUTPUT || echo "无" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### 📚 文档更新" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"* %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="^docs" >> $GITHUB_OUTPUT || echo "无" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### ⚡ 性能优化" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"* %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="^perf" >> $GITHUB_OUTPUT || echo "无" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### 🔨 其他更改" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"* %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --invert-grep --grep="^feat\|^fix\|^docs\|^perf" >> $GITHUB_OUTPUT || echo "无" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "**完整变更**: [\`$PREVIOUS_TAG...${{ steps.get_version.outputs.version }}\`](https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...${{ steps.get_version.outputs.version }})" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "changelog=🎉 **首次发布**" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download WebUI artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: webui-dist-zip | |
| path: . | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.get_version.outputs.version }} | |
| name: Release ${{ steps.get_version.outputs.version }} | |
| body: | | |
| ## 更新内容 | |
| ${{ steps.changelog.outputs.changelog }} | |
| ## Docker 镜像 | |
| ```bash | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/pallas-bot:${{ steps.get_version.outputs.version }} | |
| ``` | |
| ## WebUI 使用文档 | |
| - 主仓插件说明(自动下载/部署配置):[docs/plugins/pallas_webui/README.md](https://github.com/${{ github.repository }}/blob/${{ steps.get_version.outputs.version }}/docs/plugins/pallas_webui/README.md) | |
| - 前端仓库说明(开发/发版/对接):[PallasBot/Pallas-Bot-WebUI README](https://github.com/PallasBot/Pallas-Bot-WebUI/blob/main/README.md) | |
| ## WebUI 使用说明 | |
| 本 Release 附件中的静态资源基于 WebUI 仓库检出:**`${{ needs.build-webui-dist.outputs.webui_git_ref }}`**(`console-version.json` 中 `version`:**`${{ needs.build-webui-dist.outputs.webui_console_version }}`**)。 | |
| 默认无需手动配置,首次启用时会自动下载并部署 WebUI 静态资源。 | |
| 手动部署:下载附件 **`dist.zip`**,解压到 **`data/pallas_webui`**(得到 `data/pallas_webui/public/index.html` 等,无需改 zip 内目录名)。 | |
| files: | | |
| dist.zip | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-tagged-image: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push tagged image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| build-args: | | |
| PALLAS_BOT_VERSION=${{ steps.get_version.outputs.version }} | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/pallas-bot:${{ steps.get_version.outputs.version }} | |
| ${{ secrets.DOCKERHUB_USERNAME }}/pallas-bot:latest |