diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be69946..f47c370 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,15 +94,30 @@ jobs: path: package/*.mcdr retention-days: 5 - # 3. 发布任务 (仅当构建成功且是 Tag 推送时运行) + # 3. 发布任务 (构建成功后,如果是 Tag 推送或 Main 分支版本更新时运行) release: name: Publish Release needs: build - if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' runs-on: ubuntu-latest permissions: contents: write steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get Version info + id: version + run: | + VERSION=$(jq -r .version mcdreforged.plugin.json) + echo "VERSION=$VERSION" >> $GITHUB_ENV + if git rev-parse "v$VERSION" >/dev/null 2>&1; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + - name: Download Artifact uses: actions/download-artifact@v4 with: @@ -110,7 +125,9 @@ jobs: path: package/ - name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/v') || steps.version.outputs.exists == 'false' uses: softprops/action-gh-release@v2 with: + tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('v{0}', env.VERSION) }} files: package/*.mcdr generate_release_notes: true diff --git a/mcdreforged.plugin.json b/mcdreforged.plugin.json index 969116e..c93fb07 100644 --- a/mcdreforged.plugin.json +++ b/mcdreforged.plugin.json @@ -1,6 +1,6 @@ { "id": "sakura_flow", - "version": "0.2.3-preview2", + "version": "0.3.0", "name": "Sakura Flow", "description": "一款专注于依赖管理与深度交互的 MCDReforged 待办事项插件。", "author": "Sakura-Ex", @@ -11,4 +11,4 @@ "resources": [ "lang" ] -} \ No newline at end of file +}