Skip to content

Merge branch 'main' of https://github.com/rainbowwarmth/KazuhaBot #163

Merge branch 'main' of https://github.com/rainbowwarmth/KazuhaBot

Merge branch 'main' of https://github.com/rainbowwarmth/KazuhaBot #163

Workflow file for this run

name: Release
on:
push:
branches:
- main # 监听 main 分支的推送事件
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# 1. 检出代码
- name: Checkout code
uses: actions/checkout@v3
# 2. 获取当前版本号
- name: Get current version from package.json
id: get_version
run: |
VERSION=$(jq -r '.version' package.json)
echo "Current version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
# 3. 获取最新的 Release 版本号
- name: Get latest release version
id: get_latest_release
run: |
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.tag_name')
echo "Latest release version: $LATEST_RELEASE"
echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_ENV
# 4. 判断版本号是否有更新
- name: Check if version has changed
id: check_version
run: |
if [ "$VERSION" != "$LATEST_RELEASE" ]; then
echo "Version has changed. Proceeding with release."
echo "VERSION_UPDATED=true" >> $GITHUB_ENV
else
echo "No version update detected. Skipping release."
echo "VERSION_UPDATED=false" >> $GITHUB_ENV
fi
# 5. 使用 release-please 创建 PR,而不是直接发布
- name: Release Please Action (PR Mode)
if: env.VERSION_UPDATED == 'true'
uses: GoogleCloudPlatform/release-please-action@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
release-type: node
package-name: standard-version
version: ${{ env.VERSION }}
changelog-types: |
[
{"type": "types", "section": "Types", "hidden": false},
{"type": "revert", "section": "Reverts", "hidden": false},
{"type": "feat", "section": "Features", "hidden": false},
{"type": "fix", "section": "Bug Fixes", "hidden": false},
{"type": "improvement", "section": "Feature Improvements", "hidden": false},
{"type": "docs", "section": "Docs", "hidden": false},
{"type": "style", "section": "Styling", "hidden": false},
{"type": "refactor", "section": "Code Refactoring", "hidden": false},
{"type": "perf", "section": "Performance Improvements", "hidden": false},
{"type": "test", "section": "Tests", "hidden": false},
{"type": "build", "section": "Build System", "hidden": false},
{"type": "ci", "section": "CI", "hidden": false}
]
create-pr: true # 设置为 true 以生成发布 PR 而不是直接发布
# 6. 上传构建的发行包(在 PR 合并时执行)
- name: Upload release assets
if: env.VERSION_UPDATED == 'true'
uses: actions/upload-artifact@v3
with:
name: my-release-asset
path: ./path/to/your/build/artifacts/*.tar.gz