Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qin Kaijie
pdf-miner
Commits
07f6c497
Commit
07f6c497
authored
Jun 04, 2024
by
赵小蒙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chanage update version logic
parent
1de37e4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
23 deletions
+53
-23
python-package.yml
.github/workflows/python-package.yml
+29
-0
setup.py
setup.py
+2
-23
update_version.py
update_version.py
+22
-0
No files found.
.github/workflows/python-package.yml
View file @
07f6c497
...
...
@@ -11,6 +11,35 @@ on:
jobs
:
update-version
:
runs-on
:
ubuntu-latest
steps
:
-
name
:
Checkout repository
uses
:
actions/checkout@v4
-
name
:
Set up Python
uses
:
actions/setup-python@v5
with
:
python-version
:
"
3.10"
-
name
:
Update version.py
run
:
|
python update_version.py
-
name
:
Commit changes
run
:
|
git config --local user.email "moe@myhloli.com"
git config --local user.name "myhloli"
git add version.py
git commit -m "Update version.py with new version"
-
name
:
Push changes
env
:
GITHUB_TOKEN
:
${{ secrets.RELEASE_TOKEN }}
run
:
|
git push
build
:
runs-on
:
ubuntu-latest
...
...
setup.py
View file @
07f6c497
...
...
@@ -2,6 +2,7 @@ import os
import
subprocess
from
setuptools
import
setup
,
find_packages
from
magic_pdf.libs.version
import
__version__
def
parse_requirements
(
filename
):
...
...
@@ -20,32 +21,10 @@ def parse_requirements(filename):
return
requires
def
get_version
():
command
=
[
"git"
,
"describe"
,
"--tags"
]
try
:
version
=
subprocess
.
check_output
(
command
)
.
decode
()
.
strip
()
version_parts
=
version
.
split
(
"-"
)
if
len
(
version_parts
)
>
1
and
version_parts
[
0
]
.
startswith
(
"magic_pdf"
):
return
version_parts
[
1
]
else
:
raise
ValueError
(
f
"Invalid version tag {version}. Expected format is magic_pdf-<version>-released."
)
except
Exception
as
e
:
print
(
e
)
return
"0.0.0"
def
write_version_to_commons
(
version
):
commons_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'magic_pdf'
,
'libs'
,
'version.py'
)
with
open
(
commons_path
,
'w'
)
as
f
:
f
.
write
(
f
'__version__ = "{version}"
\n
'
)
if
__name__
==
'__main__'
:
version_name
=
get_version
()
write_version_to_commons
(
version_name
)
setup
(
name
=
"magic_pdf"
,
# 项目名
version
=
version_name
,
# 自动从tag中获取版本号
version
=
__version__
,
# 自动从tag中获取版本号
packages
=
find_packages
(),
# 包含所有的包
install_requires
=
parse_requirements
(
'requirements.txt'
),
# 项目依赖的第三方库
python_requires
=
">=3.9"
,
# 项目依赖的 Python 版本
...
...
update_version.py
0 → 100644
View file @
07f6c497
import
os
import
subprocess
def
get_version
():
command
=
[
"git"
,
"describe"
,
"--tags"
]
try
:
version
=
subprocess
.
check_output
(
command
)
.
decode
()
.
strip
()
version_parts
=
version
.
split
(
"-"
)
if
len
(
version_parts
)
>
1
and
version_parts
[
0
]
.
startswith
(
"magic_pdf"
):
return
version_parts
[
1
]
else
:
raise
ValueError
(
f
"Invalid version tag {version}. Expected format is magic_pdf-<version>-released."
)
except
Exception
as
e
:
print
(
e
)
return
"0.0.0"
def
write_version_to_commons
(
version
):
commons_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'magic_pdf'
,
'libs'
,
'version.py'
)
with
open
(
commons_path
,
'w'
)
as
f
:
f
.
write
(
f
'__version__ = "{version}"
\n
'
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment