]>
jfr.im git - yt-dlp.git/blob - devscripts/update-version.py
3 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
13 from datetime
import datetime
15 from devscripts
.utils
import read_version
, write_file
18 def get_new_version(revision
):
19 version
= datetime
.utcnow().strftime('%Y.%m.%d')
22 assert revision
.isdigit(), 'Revision must be a number'
24 old_version
= read_version().split('.')
25 if version
.split('.') == old_version
[:3]:
26 revision
= str(int((old_version
+ [0])[3]) + 1)
28 return f
'{version}.{revision}' if revision
else version
32 with contextlib
.suppress(Exception):
33 sp
= subprocess
.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout
=subprocess
.PIPE
)
34 return sp
.communicate()[0].decode().strip() or None
37 VERSION
= get_new_version((sys
.argv
+ [''])[1])
38 GIT_HEAD
= get_git_head()
41 # Autogenerated by devscripts/update-version.py
43 __version__ = {VERSION!r}
45 RELEASE_GIT_HEAD = {GIT_HEAD!r}
52 write_file('yt_dlp/version.py', VERSION_FILE
)
53 github_output
= os
.getenv('GITHUB_OUTPUT')
55 write_file(github_output
, f
'ytdlp_version={VERSION}\n', 'a')
56 print(f
'\nVersion = {VERSION}, Git HEAD = {GIT_HEAD}')