-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (118 loc) · 4.44 KB
/
nightly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Nightly Update Submodule
on:
schedule:
- cron: '0 17 * * 1-5' # At 00:00 on every day-of-week from Monday through Friday UTC +7
workflow_dispatch:
jobs:
update-submodule:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: write
outputs:
pr_number: ${{ steps.check-update.outputs.pr_number }}
pr_created: ${{ steps.check-update.outputs.pr_created }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Update submodule to latest release
id: check-update
env:
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
run: |
cd llama.cpp
latest_release=$(curl -s https://api.github.com/repos/ggerganov/llama.cpp/releases/latest | jq -r '.tag_name')
release_name=$(curl -s https://api.github.com/repos/ggerganov/llama.cpp/releases/latest | jq -r '.name')
git fetch
current_commit=$(git rev-parse HEAD)
git checkout $latest_release
new_commit=$(git rev-parse HEAD)
if [ "$current_commit" = "$new_commit" ]; then
echo "llamacpp remote repo doesn't have update today, skip nightly build"
echo "::set-output name=pr_created::false"
exit 0
fi
echo "::set-output name=pr_created::true"
cd -
git add llama.cpp
git commit -m "Update submodule to latest release $release_name"
branch_name="update-submodule-$(date +'%Y-%m-%d-%H-%M')"
git checkout -b $branch_name
git push origin $branch_name
pr_title="Update llama.cpp submodule to latest release $release_name"
pr_body="This PR updates the llama.cpp submodule to the latest release: $release_name."
gh pr create --title "$pr_title" --body "$pr_body" --head $branch_name --base main --reviewer vansangpfiev
pr_number=$(gh pr list --head $branch_name --json number --jq '.[0].number')
echo "::set-output name=pr_number::$pr_number"
check-and-merge-pr:
needs: update-submodule
if: needs.update-submodule.outputs.pr_created == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
- name: Wait for CI to pass
env:
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
run: |
pr_number=${{ needs.update-submodule.outputs.pr_number }}
while true; do
ci_status=$(gh pr checks $pr_number --json status --jq '.[0].status')
if [[ "$ci_status" == "completed" ]]; then
ci_conclusion=$(gh pr checks $pr_number --json conclusion --jq '.[0].conclusion')
if [[ "$ci_conclusion" == "success" ]]; then
echo "CI passed, merging PR..."
break
else
echo "CI failed, exiting..."
exit 1
fi
else
echo "CI is still running, waiting..."
sleep 60
fi
done
- name: Merge the PR
env:
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
run: |
pr_number=${{ needs.update-submodule.outputs.pr_number }}
gh pr merge $pr_number --merge
create-tag:
needs: [update-submodule, check-and-merge-pr]
if: needs.update-submodule.outputs.pr_created == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create and push a new tag
run: |
latest_release=$(curl -s https://api.github.com/repos/ggerganov/llama.cpp/releases/latest | jq -r '.tag_name')
date_suffix=$(date +'%d.%m.%y')
new_tag="${latest_release}-${date_suffix}"
git tag $new_tag
git push origin $new_tag