forked from harmtemolder/koreader-calibre-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·61 lines (49 loc) · 2.22 KB
/
Makefile
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
# Read the version from the version.txt file
version := $(shell head -n 1 version.txt)
zip_file = KOReader_Sync_v$(version).zip
zip_contents = about.txt LICENSE plugin-import-name-koreader.txt *.py *.md images/*.png
plugin_index_file_to_upd = pluginIndexKOReaderSync.txt
init_file_to_upd = __init__.py
release_dir = release
# Convert the version to tuple format
version_tuple := $(shell echo $(version) | awk -F. '{print "("$$1", "$$2", "$$3")"}')
# Main targets
release: update_version zip load
zip: $(release_dir)
@echo "Creating new $(release_dir)/$(zip_file)" && zip "$(release_dir)/$(zip_file)" $(zip_contents) && echo "Created new $(release_dir)/$(zip_file)"
# Loads current src content, use this if doing dev changes
dev:
@calibre-customize -b .; calibre-debug -g
# Loads zip from release dir if exists
load:
@calibre-customize -a "$(release_dir)/$(zip_file)"; calibre-debug -g
update_version: update_version_plugin_index update_version_init
@echo "Versions updated in all files."
update_version_plugin_index:
@echo "Updating version in $(plugin_index_file_to_upd) to $(version)"
@sed -i 's/Version: [^;]*;/Version: $(version);/' $(plugin_index_file_to_upd)
@echo "Version updated in $(plugin_index_file_to_upd)"
update_version_init:
@echo "Updating version in $(init_file_to_upd) to $(version_tuple)"
@sed -i '/^[[:space:]]*version = /s/version = ([0-9, ]*)/version = $(version_tuple)/' $(init_file_to_upd)
@echo "Version updated in $(init_file_to_upd)"
$(release_dir):
@mkdir -p $(release_dir)
@echo "Created $(release_dir) directory"
debug_version:
@echo "Read version: $(version)"
@echo "Version tuple: $(version_tuple)"
tag:
@echo "Tagging version v$(version) and pushing to the repository"
@if git rev-parse "v$(version)" >/dev/null 2>&1; then \
echo "Tag v$(version) already exists. Deleting the old tag."; \
git tag -d "v$(version)"; \
git push origin ":refs/tags/v$(version)"; \
fi
@git tag -a "v$(version)" -m "Version $(version)" # Create annotated tag for the version
@git push origin "v$(version)" # Push the tag to the remote repository
md_to_bb:
@echo "Converting input.md to output.forumbb"
@python .scripts/md-to-bb.py .scripts/input.md .scripts/output.forumbb
@echo "Done:"
@cat .scripts/output.forumbb