-
-
Notifications
You must be signed in to change notification settings - Fork 15
125 lines (105 loc) · 4.92 KB
/
check_version.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
name: Check new version
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1'
jobs:
build:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout ffmpeg
uses: actions/checkout@v4
with:
repository: "FFmpeg/FFmpeg"
path: 'ffmpeg'
fetch-depth: 0
- name: Checkout mpv
uses: actions/checkout@v4
with:
repository: "mpv-player/mpv"
path: 'mpv'
fetch-depth: 0
- name: Get latest verion
id: version
run: |
cd ./ffmpeg
latest_tag=$(git tag | grep n | grep -v "-" | sort -r | head -n 1)
echo "ffmpeg latest tag: $latest_tag"
echo "FFMPEG_LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
cd ..
cd ./mpv
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "mpv latest tag: $latest_tag"
echo "MPV_LATEST_VERSION=$latest_tag" >> $GITHUB_ENV
cd ..
rm -rf ./ffmpeg
rm -rf ./mpv
- 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()
mpvOldVersion = re.search(r'(case .libmpv[^"]+?)"(.+?)"', content).group(2)
print("mpv old version:", mpvOldVersion)
mpvNewVersion = '${{ env.MPV_LATEST_VERSION }}'
if parse_version(mpvNewVersion) > parse_version(mpvOldVersion):
content = re.sub(r'(case .libmpv[^"]+?)"(.+?)"', r'\1"${{ env.MPV_LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_MPV_VERSION', '1')
ffmpegOldVersion = re.search(r'(case .FFmpeg[^"]+?)"(.+?)"', content).group(2)
print("ffmpeg old version:", ffmpegOldVersion)
ffmpegNewVersion = '${{ env.FFMPEG_LATEST_VERSION }}'
if parse_version(ffmpegNewVersion) > parse_version(ffmpegOldVersion):
content = re.sub(r'(case .FFmpeg[^"]+?)"(.+?)"', r'\1"${{ env.FFMPEG_LATEST_VERSION }}"', content, count=1)
set_env('FOUND_NEW_FFMPEG_VERSION', '1')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
file_path = './README.md'
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
if parse_version(mpvNewVersion) > parse_version(mpvOldVersion):
content = re.sub(r'mpv-.*-blue', r'mpv-${{ env.MPV_LATEST_VERSION }}-blue', content, count=1)
if parse_version(ffmpegNewVersion) > parse_version(ffmpegOldVersion):
content = re.sub(r'ffmpeg-.*-blue', r'ffmpeg-${{ env.FFMPEG_LATEST_VERSION }}-blue', content, count=1)
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
- name: Create Pull Request
if: env.FOUND_NEW_MPV_VERSION && !env.FOUND_NEW_FFMPEG_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
./README.md
title: "mpv bump version to ${{ env.MPV_LATEST_VERSION }}"
body: "https://github.com/mpv-player/mpv/releases/tag/${{ env.MPV_LATEST_VERSION }}\n"
commit-message: "chore: mpv bump version to ${{ env.MPV_LATEST_VERSION }}"
- name: Create Pull Request
if: env.FOUND_NEW_FFMPEG_VERSION && !env.FOUND_NEW_MPV_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
./README.md
title: "FFmpeg bump version to ${{ env.FFMPEG_LATEST_VERSION }}"
body: "https://github.com/FFmpeg/FFmpeg/blob/${{ env.FFMPEG_LATEST_VERSION }}/Changelog\n"
commit-message: "chore: FFmpeg bump version to ${{ env.FFMPEG_LATEST_VERSION }}"
- name: Create Pull Request
if: env.FOUND_NEW_FFMPEG_VERSION && env.FOUND_NEW_MPV_VERSION
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
./Sources/BuildScripts/XCFrameworkBuild/main.swift
./README.md
title: "mpv ${{ env.MPV_LATEST_VERSION }} && FFmpeg ${{ env.FFMPEG_LATEST_VERSION }}"
body: "https://github.com/mpv-player/mpv/releases/tag/${{ env.MPV_LATEST_VERSION }}\nhttps://github.com/FFmpeg/FFmpeg/blob/${{ env.FFMPEG_LATEST_VERSION }}/Changelog\n"
commit-message: "chore: mpv ${{ env.MPV_LATEST_VERSION }} && FFmpeg ${{ env.FFMPEG_LATEST_VERSION }}"