feat: bump version for develop and main branch#95
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the version bumping workflow to support both develop and main branches with different versioning strategies. The develop branch will bump patch versions (e.g., v2.1.2 → v2.1.3) while the main branch will bump minor versions and reset patch to 0 (e.g., v2.1.2 → v2.2.0). The changes also migrate the build workflows from workflow_run triggers to repository_dispatch events for more precise control.
Changes:
- Modified bump-version.yml to trigger on both main and develop branches with branch-specific version bumping logic
- Updated all build workflows to use repository_dispatch instead of workflow_run triggers
- Changed repository dispatch event types from generic 'release' to environment-specific 'prd' and 'stg'
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/bump-version.yml | Added develop branch trigger and conditional version bumping logic; split repository dispatch into separate prd and stg events |
| .github/workflows/build-ext-stg.yml | Changed trigger from workflow_run to repository_dispatch with 'stg' event type |
| .github/workflows/build-ext-prd.yml | Changed trigger from workflow_run to repository_dispatch with 'prd' event type |
| .github/workflows/build-backend-stg.yml | Updated repository_dispatch event type from 'release' to 'stg' |
| .github/workflows/build-backend-prd.yml | Updated repository_dispatch event type from 'release' to 'prd' |
Comments suppressed due to low confidence (2)
.github/workflows/build-ext-stg.yml:14
- The checkout action is not configured to use the tag passed in the repository_dispatch event. When triggered by repository_dispatch, this workflow will checkout the default branch instead of the newly created tag. Add a 'ref' parameter to checkout the correct tag using the client_payload data, for example: 'ref: ${{ github.event.client_payload.tag }}'
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史
.github/workflows/build-ext-prd.yml:14
- The checkout action is not configured to use the tag passed in the repository_dispatch event. When triggered by repository_dispatch, this workflow will checkout the default branch instead of the newly created tag. Add a 'ref' parameter to checkout the correct tag using the client_payload data, for example: 'ref: ${{ github.event.client_payload.tag }}'
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| repository_dispatch: | ||
| types: [release] | ||
| types: [stg] |
There was a problem hiding this comment.
This workflow is now triggered by repository_dispatch with a tag in the client_payload, but the existing checkout step at line 19-20 (not shown in diff) doesn't specify a 'ref' parameter. This means it will checkout the default branch instead of the newly created tag. The checkout action needs to be updated to include 'ref: ${{ github.event.client_payload.tag }}' to checkout the correct tag version.
| repository_dispatch: | ||
| types: [release] | ||
| types: [prd] |
There was a problem hiding this comment.
This workflow is now triggered by repository_dispatch with a tag in the client_payload, but the existing checkout step at line 19-20 (not shown in diff) doesn't specify a 'ref' parameter. This means it will checkout the default branch instead of the newly created tag. The checkout action needs to be updated to include 'ref: ${{ github.event.client_payload.tag }}' to checkout the correct tag version.
| # Reassemble | ||
| new_version="${parts[0]}" | ||
| for i in $(seq 1 $last_index); do | ||
| for i in $(seq 1 $((${#parts[@]} - 1))); do |
There was a problem hiding this comment.
The version reassembly logic has an edge case issue. If the version has only one part (e.g., 'v1'), the seq command will receive 'seq 1 0' which produces no output, resulting in 'new_version' being just the major version without any dots or additional parts. Consider adding a check for the number of version parts or using a different approach to reassemble the version string.
| for i in $(seq 1 $((${#parts[@]} - 1))); do | |
| for ((i=1; i<${#parts[@]}; i++)); do |
| elif [ "$branch" = "main" ]; then | ||
| # Main branch: bump minor version and set patch to 0 | ||
| # v2.1.2 --> v2.2.0 | ||
| if [ ${#parts[@]} -ge 2 ]; then | ||
| parts[1]=$((parts[1] + 1)) | ||
| # Set patch version to 0 | ||
| if [ ${#parts[@]} -ge 3 ]; then | ||
| parts[2]=0 | ||
| fi | ||
| fi | ||
| fi |
There was a problem hiding this comment.
The main branch version bumping logic only handles cases where there are at least 2 version parts. If the version has only 1 part (e.g., 'v1'), no bumping occurs and the version remains unchanged. Consider adding an else clause to handle this edge case or ensuring that versions always have at least 3 parts (major.minor.patch).
No description provided.