Skip to content
Merged
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
54 changes: 54 additions & 0 deletions .github/workflows/auto-release-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Auto Release on PR Merge

on:
pull_request:
types: [closed]
branches: [main]

jobs:
create-tag:
name: Create release tag
if: >-
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'auto-release') &&
startsWith(github.event.pull_request.head.ref, 'release/v')
runs-on: ubuntu-latest

steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.AUTOMATION_APP_ID }}
private-key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Extract version and create tag
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
VERSION="${BRANCH_NAME#release/}"

if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Invalid version format: $VERSION"
exit 1
fi

if git ls-remote --tags --exit-code origin "refs/tags/$VERSION" >/dev/null 2>&1; then
echo "::error::Tag $VERSION already exists on origin"
exit 1
fi

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git tag -a "${VERSION}" "${MERGE_COMMIT_SHA}" -m "Release ${VERSION}"
git push origin "${VERSION}"

echo "✅ Tag ${VERSION} created on commit ${MERGE_COMMIT_SHA}"
25 changes: 25 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Auto Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Auto Release from CHANGELOG
uses: wuji-technology/.github/actions/auto-release@24ff1d553c7541f5385c0d2498309c49e8c5ef5e # main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
feishu-webhook: ${{ secrets.FEISHU_RELEASE_WEBHOOK }}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Added

- `auto-release-on-pr.yml` workflow for creating tags on PR merge with `auto-release` label
- `auto-release.yml` workflow for creating GitHub Release on tag push
- Support custom CHANGELOG path in centralized release (`repo=version:changelog_path`)
- Centralized multi-version release workflow (`centralized-release.yml`)
- `parse-repos.py` script for parsing multi-line repo=version input
Expand Down
4 changes: 2 additions & 2 deletions scripts/parse-repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def parse_repos(input_text):
if not line or line.startswith('#'):
continue

# 匹配 repo=version
match = re.match(r'^([a-zA-Z0-9_-]+)\s*=\s*(.+)$', line)
# 匹配 repo=version(支持点号,如 .github)
match = re.match(r'^([a-zA-Z0-9_.-]+)\s*=\s*(.+)$', line)
if not match:
raise ValueError(f"第 {line_num} 行格式错误: {line}\n正确格式: repo=version")

Expand Down