-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate-version.sh
More file actions
executable file
·78 lines (64 loc) · 2.14 KB
/
generate-version.sh
File metadata and controls
executable file
·78 lines (64 loc) · 2.14 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
set -e
# Generate version information for the Booklore KOReader plugin
# This script extracts version from git tags (semantic-release) or uses a dev version
VERSION_FILE="bookloresync.koplugin/plugin_version.lua"
echo "Generating version information..."
# Get git commit hash (if available)
GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Try to get version from git tags
if git describe --tags --exact-match HEAD 2>/dev/null; then
# We're on a tagged commit (release)
VERSION=$(git describe --tags --exact-match HEAD)
VERSION_TYPE="release"
echo "Found release tag: $VERSION"
elif git describe --tags 2>/dev/null; then
# We're on a commit after a tag
VERSION=$(git describe --tags --always)
VERSION_TYPE="development"
echo "Using development version: $VERSION"
elif [ "$GIT_COMMIT" != "unknown" ]; then
# No tags but we have commits, use commit as version
VERSION="0.0.0-dev+$GIT_COMMIT"
VERSION_TYPE="development"
echo "No git tags found, using commit-based version: $VERSION"
else
# No tags and no commits, use default version
VERSION="0.0.0-dev"
VERSION_TYPE="development"
echo "No git tags or commits found, using default: $VERSION"
fi
# Get build date
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Generate version.lua file
cat > "$VERSION_FILE" <<EOF
--[[--
Booklore Plugin Version Information
Auto-generated by generate-version.sh
DO NOT EDIT THIS FILE MANUALLY
@module koplugin.BookloreSync.version
--]]--
return {
version = "$VERSION",
version_type = "$VERSION_TYPE",
git_commit = "$GIT_COMMIT",
build_date = "$BUILD_DATE",
}
EOF
echo "Version file generated: $VERSION_FILE"
echo " Version: $VERSION"
echo " Type: $VERSION_TYPE"
echo " Commit: $GIT_COMMIT"
echo " Build Date: $BUILD_DATE"
# Also update _meta.lua with version
META_FILE="bookloresync.koplugin/_meta.lua"
cat > "$META_FILE" <<EOF
local _ = require("gettext")
return {
name = "booklore",
fullname = _("Booklore Sync"),
description = _([[Sync your reading sessions to Booklore server.]]),
version = "$VERSION",
}
EOF
echo "_meta.lua updated with version: $VERSION"