Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Sep 12, 2024
1 parent 5908334 commit 192d8b8
Showing 1 changed file with 28 additions and 37 deletions.
65 changes: 28 additions & 37 deletions .github/workflows/upgrade-version-by-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
# title: "Update version to $TAG_VERSION"
# body: "This PR updates the version file to the new tag version $TAG_VERSION."


name: Upgrade version by tag

permissions:
Expand All @@ -78,6 +77,9 @@ on:
jobs:
upgrade_version:
runs-on: ubuntu-latest
env:
TAG_VERSION: ${{ github.ref_name }} # 使用GitHub提供的ref_name来捕获tag名称
BRANCH_NAME: update-version-${{ github.ref_name }} # 设置BRANCH_NAME为新的版本分支
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
Expand All @@ -92,43 +94,32 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# # Step 3: Add remote pointing to the forked repository
# - name: Add fork remote
# run: |
# git remote add fork https://github.com/github-actions[bot]/actions-test-fork.git # 替换为官方账号的 fork 仓库
# git fetch fork

# # Step 4: Create a new branch in the fork
# - name: Create new branch for version update
# run: |
# TAG_VERSION=${GITHUB_REF#refs/tags/}
# BRANCH_NAME="update-version-${TAG_VERSION}"
# git checkout -b $BRANCH_NAME

# # Step 5: Update version file
# - name: Update version file
# run: |
# TAG_VERSION=${GITHUB_REF#refs/tags/}
# echo "$TAG_VERSION" > version/version
# git add version/version
# git commit -m "Update version to $TAG_VERSION"

# # Step 6: Push the new branch to the forked repository
# - name: Push to forked repository
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用 GITHUB_TOKEN 进行身份验证
# run: |
# TAG_VERSION=${GITHUB_REF#refs/tags/}
# BRANCH_NAME="update-version-${TAG_VERSION}"
# git push fork $BRANCH_NAME

# Step 7: Create a Pull Request from the fork to the original repository
# Step 3: Create a new branch for version update
- name: Create new branch for version update
run: |
git checkout -b ${{ env.BRANCH_NAME }}
# Step 4: Update version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > version/version
git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
# Step 5: Push the new branch to the repository
- name: Push to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用 GITHUB_TOKEN 进行身份验证
run: |
git push origin ${{ env.BRANCH_NAME }}
# Step 6: Create a Pull Request from the new branch to the original repository
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: "Update version to $TAG_VERSION"
branch: $BRANCH_NAME
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update version to ${{ env.TAG_VERSION }}"
branch: ${{ env.BRANCH_NAME }}
base: main # 原始仓库的目标分支
title: "Update version to $TAG_VERSION"
body: "This PR updates the version file to the new tag version $TAG_VERSION."
title: "Update version to ${{ env.TAG_VERSION }}"
body: "This PR updates the version file to the new tag version ${{ env.TAG_VERSION }}."

0 comments on commit 192d8b8

Please sign in to comment.