From 7b65a3be67cf418b24569f023b042305e4e9eb79 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 15 Nov 2026 22:38:13 +0800 Subject: [PATCH 1/2] ci: gate Maven publishing behind explicit releases --- .github/workflows/maven-publish.yml | 48 ++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index f13f26a80..d8052731f 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -3,17 +3,56 @@ on: push: branches: - develop + # Maintainers can publish a timestamped build from develop on demand. + workflow_dispatch: permissions: contents: write -concurrency: - group: maven-publish-${{ github.ref }} - cancel-in-progress: true - jobs: + check-publish: + if: github.ref == 'refs/heads/develop' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + should_publish: ${{ steps.publish_guard.outputs.should_publish }} + steps: + - name: Checkout Code + uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Check whether publication was requested + id: publish_guard + env: + EVENT_NAME: ${{ github.event_name }} + EVENT_REF: ${{ github.ref }} + run: | + # Expressions compare strings case-insensitively; require the exact branch here. + if [[ "$EVENT_REF" != "refs/heads/develop" ]]; then + echo "should_publish=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + COMMIT_MSG=$(git log -1 --pretty=%B) + SHOULD_PUBLISH="false" + if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then + SHOULD_PUBLISH="true" + elif [[ "$COMMIT_MSG" =~ ^:bookmark:\ 发布\ ([0-9]+\.[0-9]+\.[0-9]+)\.B\ 测试版本 ]] || + [[ "$COMMIT_MSG" =~ ^:bookmark:\ 发布\ ([0-9]+\.[0-9]+\.[0-9]+)\ 正式版本 ]]; then + SHOULD_PUBLISH="true" + fi + echo "should_publish=$SHOULD_PUBLISH" >> "$GITHUB_OUTPUT" + build-and-publish: + needs: check-publish + if: github.ref == 'refs/heads/develop' && needs.check-publish.outputs.should_publish == 'true' runs-on: ubuntu-latest + # Ordinary pushes never enter this group or cancel an intentional release. + concurrency: + group: maven-publish-${{ github.ref }} + cancel-in-progress: false + queue: max steps: - name: Checkout Code @@ -22,6 +61,7 @@ jobs: fetch-depth: 0 - name: Detect and tag release version from commit message + if: github.event_name == 'push' id: version_detect run: | COMMIT_MSG=$(git log -1 --pretty=%B) From 32bec6fcc8cb6b3764a9f6e41274695f42d6fb3a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 16 Nov 2026 11:47:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20Maven=20?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E7=89=88=E5=8F=91=E5=B8=83=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 849abb6b1..2fad11968 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ System.out.println(result.getOpenid()); 点此展开查看 1. 本项目定为大约每半年左右发布一次正式版,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交 `Pull Request`; -2. 每次代码更新都会自动构建出新版本方便及时尝鲜,版本号格式为 `x.x.x-时间戳`; +2. 普通 `develop` 提交只跑测试,不自动发布;需要提前验证修复时,维护者可在 GitHub Actions 手动发布 `x.x.x-时间戳` 版本。 3. 发布正式版时,`develop` 分支代码合并进入 `release` 分支),版本号格式为 `X.X.0`(如`2.1.0`,`2.2.0`等); 4. 每隔一段时间后,会发布测试版本(如`3.6.8.B`,即尾号不为0,并添加B,以区别于正式版),代码仅存在于 `develop` 分支中; 5. 目前最新版本号为 [![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/wx-java.svg)](http://mvnrepository.com/artifact/com.github.binarywang/wx-java) ,也可以通过访问以下链接分别查看各个模块最新的版本: