-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dump local helper dev scripts in case it's useful to someone else
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
overdrive-libby-plugin-v*.zip | ||
calibre-plugin/commit.txt | ||
|
||
.env | ||
|
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,64 @@ | ||
# Replaces old version number for the new one | ||
import argparse | ||
import re | ||
from pathlib import Path | ||
|
||
version_sub_re = re.compile(r"__version__ = \(\d+, \d+, \d+\)") | ||
version_re = re.compile(r"\d+\.\d+\.\d+") | ||
|
||
|
||
def version_num(value: str): | ||
if not version_re.match(value): | ||
raise argparse.ArgumentTypeError( | ||
f'"{value}" is an invalid version number format' | ||
) | ||
return value | ||
|
||
|
||
def run(src_file: str, new_version: str): | ||
temp_path = Path(f"{src_file}.temp") | ||
src_path = Path(src_file) | ||
with src_path.open("r", encoding="utf-8") as f_in, temp_path.open( | ||
"w", encoding="utf-8" | ||
) as f_out: | ||
while True: | ||
line = f_in.readline() | ||
if not line: | ||
break | ||
mobj = version_sub_re.search(line) | ||
if not mobj: | ||
f_out.write(line) | ||
continue | ||
version_tuple = new_version.split(".") | ||
new_line = version_sub_re.sub( | ||
f'__version__ = ({", ".join(version_tuple)})', | ||
line, | ||
) | ||
print( | ||
f"{src_file}:\n" | ||
f"* before:\t{line.strip()}" | ||
f"\n* after:\t{new_line.strip()}" | ||
) | ||
f_out.write(new_line) | ||
temp_path.rename(src_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Bump version") | ||
parser.add_argument( | ||
"new_version", type=version_num, help="New version number. Format d.d.d" | ||
) | ||
|
||
args = parser.parse_args() | ||
src_files = ("calibre-plugin/__init__.py",) | ||
for src in src_files: | ||
run(src, args.new_version) | ||
|
||
print(f'\nROLLBACK git commands:\ngit restore {" ".join(src_files)}\n') | ||
|
||
print( | ||
f'COMMIT git commands:\ngit add -u {" ".join(src_files)} calibre-plugin/translations/ translate.sh' | ||
) | ||
print(f"git commit -m 'Bump version to {args.new_version}'") | ||
print(f"git tag --sign -a 'v{args.new_version}' -m 'Release v{args.new_version}'") | ||
print("git push && git push --tags\n") |
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,12 @@ | ||
# Helper bash script to update versions and prompt for commands to run - macOS | ||
# Does not commit to git because we usually have to also update screenshots, readme, changelog, etc | ||
if [[ -z "$1" ]]; then | ||
echo "Please specify a version number, e.g. 0.1.2" | ||
exit | ||
fi | ||
|
||
version="$1" | ||
|
||
python3 bump_version.py "$version" && \ | ||
sed -i '' -e "s/'[0-9]*\.[0-9]*\.[0-9]*'/'${version}'/g" translate.sh && \ | ||
sh translate.sh "$version" |
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,8 @@ | ||
# Helper bash script to start calibre debug with the latest plugin code loaded - macOS | ||
for f in calibre-plugin/translations/*.po | ||
do | ||
echo "Building ${f%\.po} into ${f%\.po}.mo" | ||
msgfmt -o "${f%\.po}.mo" "${f%\.po}" | ||
done | ||
echo "$(git rev-parse HEAD)" > calibre-plugin/commit.txt | ||
calibre-debug -s; calibre-customize -b calibre-plugin; CALIBRE_OVERRIDE_LANG=en calibre-debug -g |
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,7 @@ | ||
# Helper bash script to bundle a dev zip for local testing - macOS | ||
version="$(git rev-parse HEAD)" | ||
rm -f overdrive-libby-plugin-v*.zip | ||
echo "$(git rev-parse HEAD)" > calibre-plugin/commit.txt | ||
cd calibre-plugin && \ | ||
zip --quiet -r ../"overdrive-libby-plugin-v${version::7}.$(date +%H%M%S).zip" ./* && \ | ||
cd .. |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Helper bash script to update and build translations files - macOS | ||
if [[ -z "$1" ]]; then | ||
version='0.1.8' | ||
else | ||
|