mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-06 04:10:02 +08:00
🐳 chore(update_version): 支持选择性的更新版本 (#1691)
* 🐳 chore(update_version): 支持选择性的更新版本 * 🐳 chore: 替换邮箱格式
This commit is contained in:
@@ -1,14 +1,12 @@
|
|||||||
name: Update Version
|
name: Update Version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
push:
|
||||||
paths:
|
paths:
|
||||||
|
- .github/workflows/update_version_pr.yml
|
||||||
- zhenxun/**
|
- zhenxun/**
|
||||||
- resources/**
|
- resources/**
|
||||||
- bot.py
|
- bot.py
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- dev
|
- dev
|
||||||
@@ -20,7 +18,7 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
- name: Read current version
|
- name: Read current version
|
||||||
id: read_version
|
id: read_version
|
||||||
@@ -46,20 +44,30 @@ jobs:
|
|||||||
run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update version file
|
- name: Update version file
|
||||||
|
id: update_version
|
||||||
if: steps.check_diff.outputs.version_changed == 'false'
|
if: steps.check_diff.outputs.version_changed == 'false'
|
||||||
run: |
|
run: |
|
||||||
current_version="${{ steps.read_version.outputs.current_version }}"
|
current_version="${{ steps.read_version.outputs.current_version }}"
|
||||||
commit_hash="${{ steps.get_commit_hash.outputs.commit_hash }}"
|
commit_hash="${{ steps.get_commit_hash.outputs.commit_hash }}"
|
||||||
new_version="v${current_version}-${commit_hash}"
|
new_version="v${current_version}-${commit_hash}"
|
||||||
|
echo "new_version=$new_version" >> $GITHUB_OUTPUT
|
||||||
echo "Updating version to: $new_version"
|
echo "Updating version to: $new_version"
|
||||||
echo "__version__: $new_version" > __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
|
- name: Check updated version
|
||||||
if: steps.check_diff.outputs.version_changed == 'false'
|
if: steps.check_diff.outputs.version_changed == 'false'
|
||||||
run: cat __version__
|
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
|
||||||
Reference in New Issue
Block a user