mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
🐳 chore(update_version): 支持选择性的更新版本 (#1691)
* 🐳 chore(update_version): 支持选择性的更新版本 * 🐳 chore: 替换邮箱格式
This commit is contained in:
parent
9e5266a491
commit
faa0785fa1
@ -1,14 +1,12 @@
|
||||
name: Update Version
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
push:
|
||||
paths:
|
||||
- .github/workflows/update_version_pr.yml
|
||||
- zhenxun/**
|
||||
- resources/**
|
||||
- bot.py
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
@ -20,7 +18,7 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Read current version
|
||||
id: read_version
|
||||
@ -46,20 +44,30 @@ jobs:
|
||||
run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update version file
|
||||
id: update_version
|
||||
if: steps.check_diff.outputs.version_changed == 'false'
|
||||
run: |
|
||||
current_version="${{ steps.read_version.outputs.current_version }}"
|
||||
commit_hash="${{ steps.get_commit_hash.outputs.commit_hash }}"
|
||||
new_version="v${current_version}-${commit_hash}"
|
||||
echo "new_version=$new_version" >> $GITHUB_OUTPUT
|
||||
echo "Updating version to: $new_version"
|
||||
echo "__version__: $new_version" > __version__
|
||||
git config --global user.name "${{ github.event.pull_request.user.login }}"
|
||||
git config --global user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com"
|
||||
git add __version__
|
||||
git remote set-url origin https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
|
||||
git commit -m "chore(version): Update version to $new_version"
|
||||
git push origin HEAD:${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: Check updated version
|
||||
if: steps.check_diff.outputs.version_changed == 'false'
|
||||
run: cat __version__
|
||||
|
||||
- name: Create or update PR
|
||||
if: steps.check_diff.outputs.version_changed == 'false'
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
branch: create-pr/update_version
|
||||
title: ":tada: chore(version): 自动更新版本到 ${{ steps.update_version.outputs.new_version }}"
|
||||
body: "This PR updates the version file."
|
||||
commit-message: ":tada: chore(version): Update version to ${{ steps.update_version.outputs.new_version }}"
|
||||
add-paths: __version__
|
||||
author: "AkashiCoin <i@loli.vet>"
|
||||
committer: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>"
|
||||
labels: automated-update
|
||||
Loading…
Reference in New Issue
Block a user