Enhance build-and-release workflow to handle merge conflicts and improve version update logic
This commit is contained in:
@ -11,6 +11,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -60,9 +64,18 @@ jobs:
|
|||||||
|
|
||||||
- name: Commit version update
|
- name: Commit version update
|
||||||
run: |
|
run: |
|
||||||
git pull origin main
|
# Pull changes and handle potential merge conflicts
|
||||||
|
git pull origin main || true
|
||||||
|
|
||||||
|
# If conflict occurs, keep both version entries
|
||||||
|
if git diff --name-only --diff-filter=U | grep -q "versions.txt"; then
|
||||||
|
git checkout --ours versions.txt
|
||||||
|
echo "New version: ${{ env.VERSION }}" >> versions.txt
|
||||||
|
git add versions.txt
|
||||||
|
fi
|
||||||
|
|
||||||
git add versions.txt
|
git add versions.txt
|
||||||
git commit -m "Update to version ${{ env.VERSION }} [skip ci]"
|
git commit -m "Update to version ${{ env.VERSION }} [skip ci]" || echo "No changes to commit"
|
||||||
git push origin main
|
git push origin main
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
|
Reference in New Issue
Block a user