2424 - name : Checkout repository
2525 uses : actions/checkout@v4
2626 with :
27- fetch-depth : 0
27+ fetch-depth : 1 # Fetch only the latest commit
2828 token : ${{ secrets.PAT_SERVICE_ACCOUNT }}
2929 ref : master
3030
@@ -33,26 +33,33 @@ jobs:
3333 git config --global user.name 'github-actions[bot]'
3434 git config --global user.email 'github-actions[bot]@users.noreply.github.com'
3535
36- - name : Add upstream remote and fetch latest release
36+ - name : Add upstream remote
3737 env :
3838 GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
3939 run : |
40- git remote add upstream https://github.com/ggml-org/llama.cpp.git
41- git fetch upstream --prune --unshallow --tags
40+ git remote add upstream https://github.com/ggml-org/llama.cpp.git || true
41+ git fetch upstream --prune --tags --depth=1 # Fetch only necessary tags
4242
43+ - name : Get Latest Release Tag
44+ env :
45+ GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
46+ run : |
4347 LATEST_RELEASE_TAG=$(curl -s https://api.github.com/repos/ggml-org/llama.cpp/releases/latest | jq -r '.tag_name')
44-
48+
4549 if [ -z "$LATEST_RELEASE_TAG" ] || [ "$LATEST_RELEASE_TAG" = "null" ]; then
4650 echo "No valid release found. Exiting."
4751 exit 1
4852 fi
49-
53+
5054 echo "Latest release tag: $LATEST_RELEASE_TAG"
51- git fetch upstream $LATEST_RELEASE_TAG
52- git checkout $LATEST_RELEASE_TAG
55+ echo "LATEST_RELEASE_TAG=$LATEST_RELEASE_TAG" >> $GITHUB_ENV
5356
54- git reset --hard upstream/$LATEST_RELEASE_TAG
55- git push origin HEAD:master --force
57+ - name : Sync Master with Latest Release
58+ run : |
59+ LATEST_RELEASE_TAG=${{ env.LATEST_RELEASE_TAG }}
60+ git fetch upstream $LATEST_RELEASE_TAG --depth=1
61+ git checkout -B master $LATEST_RELEASE_TAG
62+ git push origin master --force
5663
5764 - name : Create PR to merge master into dev
5865 id : create-pr
@@ -65,14 +72,18 @@ jobs:
6572 PR_TITLE="Sync master (latest release) → dev"
6673 PR_BODY="This PR updates the dev branch with the latest release from ggml-org/llama.cpp"
6774
68- gh pr create --title "$PR_TITLE" --body "$PR_BODY" --head update-dev-from-master --base dev --reviewer vansangpfiev || echo "PR already exists."
69-
70- PR_NUMBER=$(gh pr list --head update-dev-from-master --json number --jq '.[0].number')
71- echo "pr_number=$PR_NUMBER" >> $GITHUB_ENV
72- echo "::set-output name=pr_number::$PR_NUMBER"
73- echo "::set-output name=pr_created::true"
75+ PR_NUMBER=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --head update-dev-from-master --base dev --reviewer vansangpfiev --json number --jq '.number' || echo "")
76+
77+ if [[ -z "$PR_NUMBER" ]]; then
78+ echo "PR already exists or failed to create."
79+ echo "::set-output name=pr_created::false"
80+ else
81+ echo "PR created: #$PR_NUMBER"
82+ echo "::set-output name=pr_number::$PR_NUMBER"
83+ echo "::set-output name=pr_created::true"
84+ fi
7485
75- - name : Count commits for tagging
86+ - name : Count Commits for Tagging
7687 id : commit-count
7788 run : |
7889 COMMIT_COUNT=$(git rev-list --count HEAD)
@@ -90,17 +101,17 @@ jobs:
90101 - name : Checkout repository
91102 uses : actions/checkout@v4
92103 with :
93- fetch-depth : 0
104+ fetch-depth : 1
94105 token : ${{ secrets.PAT_SERVICE_ACCOUNT }}
95106 ref : dev
96107
97- - name : Check PR mergeability
108+ - name : Check PR Mergeability
98109 env :
99110 GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
100111 run : |
101112 PR_NUMBER=${{ needs.sync-master.outputs.pr_number }}
102113 MERGE_STATUS=$(gh pr view $PR_NUMBER --json mergeable --jq '.mergeable')
103-
114+
104115 if [[ "$MERGE_STATUS" == "MERGEABLE" ]]; then
105116 echo "PR is mergeable, proceeding with merge."
106117 else
@@ -122,7 +133,7 @@ jobs:
122133 - name : Checkout repository
123134 uses : actions/checkout@v4
124135 with :
125- fetch-depth : 0
136+ fetch-depth : 1
126137 token : ${{ secrets.PAT_SERVICE_ACCOUNT }}
127138 ref : dev
128139
@@ -131,7 +142,7 @@ jobs:
131142 git config --global user.name 'github-actions[bot]'
132143 git config --global user.email 'github-actions[bot]@users.noreply.github.com'
133144
134- - name : Create and push tag
145+ - name : Create and Push Tag
135146 env :
136147 GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
137148 run : |
0 commit comments