Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ System.out.println(result.getOpenid());
<summary>点此展开查看</summary>

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) ,也可以通过访问以下链接分别查看各个模块最新的版本:
Expand Down
Loading