From f761bf271051730cf5a7fe3b0a3286a1a3d3a50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sun, 4 Aug 2024 14:46:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=20Github=20Actions=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=20Release=20=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.github/workflows/release.yml | 51 ++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/plugin/think-plugs-wechat/.github/workflows/release.yml b/plugin/think-plugs-wechat/.github/workflows/release.yml index 94c8d25c0..20e0bad38 100644 --- a/plugin/think-plugs-wechat/.github/workflows/release.yml +++ b/plugin/think-plugs-wechat/.github/workflows/release.yml @@ -4,23 +4,62 @@ on: tags: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 -name: Release +name: Create Release permissions: write-all jobs: release: - name: Release runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install dependencies + run: npm install -g gen-git-log + + - name: Find Last Tag + id: last_tag + run: | + + # 获取所有标签,按版本排序(降序) + Tags=$(git tag --list --sort=-version:refname) + + # 获取最新的标签(即列表中的第一个) + LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $1; exit}') + + # 获取倒数第二个标签(如果存在) + if [[ -n "$Tags" ]]; then + # 使用 tail 获取除了最后一个标签之外的所有标签,然后用 head 获取第一个 + SECOND_LATEST_TAG=$(echo "$Tags" | tail -n +2 | head -n 1) + else + SECOND_LATEST_TAG="" + fi + + # 设置输出变量 + echo "::set-output name=tag_last::${LATEST_TAG:-v1.0.0}" + echo "::set-output name=tag_second::${SECOND_LATEST_TAG:-v1.0.0}" + + - name: Generate Release Notes + run: | + rm -rf log + newTag=${{ steps.last_tag.outputs.tag_last }} + git-log -m tag -f -S ${{ steps.last_tag.outputs.tag_second }} -v ${newTag#v} + - name: Create Release id: create_release uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + tag_name: ${{ steps.last_tag.outputs.tag_last }} + release_name: Release ${{ steps.last_tag.outputs.tag_last }} + body_path: log/${{steps.last_tag.outputs.tag_last}}.md draft: false - prerelease: false + prerelease: false \ No newline at end of file