فهرست منبع

【维护】更新版本号和工作流配置

PJ568 1 سال پیش
والد
کامیت
3e570e1dc0
3فایلهای تغییر یافته به همراه59 افزوده شده و 57 حذف شده
  1. 48 45
      .github/workflows/release.yml
  2. 10 11
      .github/workflows/test.yml
  3. 1 1
      clean_trash.sh

+ 48 - 45
.github/workflows/release.yml

@@ -6,7 +6,10 @@ on:
       - master
 
 jobs:
+  test:
+    uses: ./.github/workflows/test.yml
   release:
+    needs: test
     runs-on: ubuntu-latest
     permissions:
       contents: write
@@ -14,53 +17,53 @@ jobs:
       id-token: write
     name: 发行新版本
     steps:
-    - name: 检出代码
-      uses: actions/checkout@v4
-      with:
-        fetch-depth: 0
+      - name: 检出代码
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
-    - name: 检查版本
-      id: version-check
-      run: |
-        VERSION=$(./scripts/is-newer-version.bash)
-        echo "version=${VERSION}" >> $GITHUB_OUTPUT
-        if [ "$VERSION" != "0" ]; then
-          echo "检测到新版本: $VERSION"
-        else
-          echo "没有新版本需要发行"
-        fi
+      - name: 检查版本
+        id: version-check
+        run: |
+          VERSION=$(./scripts/is-newer-version.bash)
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          if [ "$VERSION" != "0" ]; then
+            echo "检测到新版本: $VERSION"
+          else
+            echo "没有新版本需要发行"
+          fi
 
-    - name: 推送标签
-      if: steps.version-check.outputs.version != '0'
-      id: push-tag
-      run: |
-        tag="v${{ steps.version-check.outputs.version }}"
-        git config user.name "${GITHUB_ACTOR}"
-        git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
-        git tag -a "${tag}" -m "Release ${tag}"
-        git push origin "${tag}"
-        echo "tag_name=${tag}" >> $GITHUB_OUTPUT
+      - name: 推送标签
+        if: steps.version-check.outputs.version != '0'
+        id: push-tag
+        run: |
+          tag="v${{ steps.version-check.outputs.version }}"
+          git config user.name "${GITHUB_ACTOR}"
+          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git tag -a "${tag}" -m "Release ${tag}"
+          git push origin "${tag}"
+          echo "tag_name=${tag}" >> $GITHUB_OUTPUT
 
-    - name: 准备发行文件
-      if: steps.version-check.outputs.version != '0'
-      run: |
-        mkdir -p ../release
-        cp -v clean_trash.sh ../release/clean_trash
-        # 确保脚本具有执行权限
-        chmod +x ../release/clean_trash
+      - name: 准备发行文件
+        if: steps.version-check.outputs.version != '0'
+        run: |
+          mkdir -p ../release
+          cp -v clean_trash.sh ../release/clean_trash
+          # 确保脚本具有执行权限
+          chmod +x ../release/clean_trash
 
-    - name: 创建 GitHub Release
-      if: steps.version-check.outputs.version != '0'
-      uses: ncipollo/release-action@v1
-      with:
-        generateReleaseNotes: true
-        tag: "v${{ steps.version-check.outputs.version }}"
-        artifacts: "../release/clean_trash"
+      - name: 创建 GitHub Release
+        if: steps.version-check.outputs.version != '0'
+        uses: ncipollo/release-action@v1
+        with:
+          generateReleaseNotes: true
+          tag: "v${{ steps.version-check.outputs.version }}"
+          artifacts: "../release/clean_trash"
 
-    - name: 删除标签(如果失败)
-      if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
-      run: |
-        git config user.name "${GITHUB_ACTOR}"
-        git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
-        git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
-        git tag -d "${{ steps.push-tag.outputs.tag_name }}"
+      - name: 删除标签(如果失败)
+        if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
+        run: |
+          git config user.name "${GITHUB_ACTOR}"
+          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
+          git tag -d "${{ steps.push-tag.outputs.tag_name }}"

+ 10 - 11
.github/workflows/test.yml

@@ -1,25 +1,24 @@
 name: 测试与验证
 
 on:
-  push:
-    branches:
-      - master
+  workflow_dispatch:
   pull_request:
     branches:
       - master
+  workflow_call:
 
 jobs:
   test:
     runs-on: ubuntu-latest
 
     steps:
-    - name: 检出代码
-      uses: actions/checkout@v4
+      - name: 检出代码
+        uses: actions/checkout@v4
 
-    - name: 设置环境
-      run: |
-        chmod +x clean_trash.sh
-        chmod +x scripts/test_clean_trash.sh
+      - name: 设置环境
+        run: |
+          chmod +x clean_trash.sh
+          chmod +x scripts/test_clean_trash.sh
 
-    - name: 运行测试
-      run: ./scripts/test_clean_trash.sh
+      - name: 运行测试
+        run: ./scripts/test_clean_trash.sh

+ 1 - 1
clean_trash.sh

@@ -3,7 +3,7 @@
 # 设置定量 | Quantities
 ## 初始化变量 | Initialize variables
 VERBOSE=0
-VERSION="1.0.1"
+VERSION="1.0.2"
 ## 当前语言 | Current language
 CURRENT_LANG=0 # 0: en-US, 1: zh-Hans-CN
 ## 定义回收站目录 | Define trash directory