-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 "[email protected]" | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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') |