Repository navigation
69 lines (59 loc) · 2.3 KB
/
Copy pathcheck_version.yml
File metadata and controls
69 lines (59 loc) · 2.3 KB
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
name: Check new version
on:
workflow_dispatch:
# schedule:
# - cron: '0 0 1 * *' # every month first day
jobs:
build:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout latest code
uses: actions/checkout@v4
with:
repository: "ggml-org/whisper.cpp"
path: 'latest_code'
fetch-depth: 0
- name: Get latest verion
id: version
run: |
cd ./latest_code
latest_tag=$(git tag --sort=-v:refname | grep -v "-" | head -n 1)
echo "latest tag: $latest_tag"
echo "LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
rm -rf ../latest_code
- name: update to new version
uses: jannekem/run-python-script-action@v1
with:
script: |
import re
def parse_version(ver):
if '-' in ver or ver == '':
return 0
return int(re.sub(r'[^0-9]+', r'', ver))
file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift'
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
oldVersion = re.search(r'(case .whisper[^"]+?)"(.+?)"', content).group(2)
print("old version:", oldVersion)
set_env('OLD_VERSION', oldVersion)
newVersion = '${{ env.LATEST_VERSION }}'
print("new version:", newVersion)
if parse_version(newVersion) > parse_version(oldVersion):
content = re.sub(r'(case .whisper[^"]+?)"(.+?)"', r'\1"${{ env.LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_VERSION', '1')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
- name: Create Pull Request
if: env.FOUND_NEW_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
title: "bump version to ${{ env.LATEST_VERSION }}"
body: |
https://github.com/ggml-org/whisper.cpp/compare/${{ env.OLD_VERSION }}...${{ env.LATEST_VERSION }}
commit-message: "chore: bump version to ${{ env.LATEST_VERSION }}"