-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag
More file actions
executable file
·173 lines (136 loc) · 5.07 KB
/
Copy pathtag
File metadata and controls
executable file
·173 lines (136 loc) · 5.07 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/env bash
set -euo pipefail
# NOTE: Do not use the generic bump script for this application, there are subtle differences.
conf_file="version.conf"
# Default suffix
suffix=""
# Parse command-line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-t|--type)
shift
case ${1:-} in
dev|rc1|rel)
suffix="$1"
;;
*)
echo "Error: Suffix must be 'dev', 'rc1', or 'rel'. Got '${1:-}'." >&2
exit 1
;;
esac
shift
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
if [ -z "$suffix" ]; then
echo "Error: --type must be provided (dev, rc1, or rel)" >&2
exit 1
fi
# No suffix for release
if [[ $suffix == "rel" ]]; then
suffix=""
fi
# Ensure we run from the repository root
repo_root=$(git rev-parse --show-toplevel)
cd "$repo_root" || exit 1
# Ensure version.conf exists and has defaults
if [[ ! -f "$conf_file" ]]; then
cat > "$conf_file" <<EOF
major=0
minor=0
patch=0
EOF
fi
# Source version file (safe)
# shellcheck disable=SC1090
source "$conf_file"
# Ensure numeric values (fallback to 0)
major=${major:-0}
minor=${minor:-0}
patch=${patch:-0}
# Increment patch
patch=$((patch + 1))
# Save updated version
cat > "$conf_file" <<EOF
major=$major
minor=$minor
patch=$patch
EOF
# Build version string
name="wk2gtkpdf"
version="$major.$minor.$patch"
# 1. Prepare the Debian-style date (Required for the footer)
# Format: Mon, 22 Feb 2026 22:45:00 +0000
DEB_DATE=$(date -R)
# 2. Build the new Header and Footer
# Note: 'unstable' or 'trixie' is the target distribution
CHANGELOG_HEADER="wkgtk-html2pdf (${version}-1) unstable; urgency=medium"
CHANGELOG_HEADER_LITE="wkgtk-html2pdf-lite (${version}-1) unstable; urgency=medium"
CHANGELOG_FOOTER=" -- James Hothersall <james@wkgtk-html2pdf.com> $DEB_DATE"
# 3. Prepend to the existing changelog
# We create a temporary file, add the new entry, then append the old content
if [ -f "debian/changelog" ]; then
echo "$CHANGELOG_HEADER" > debian/changelog.new
echo "" >> debian/changelog.new
echo " * Automated release: Version ${version}" >> debian/changelog.new
echo "" >> debian/changelog.new
echo "$CHANGELOG_FOOTER" >> debian/changelog.new
echo "" >> debian/changelog.new
cat debian/changelog >> debian/changelog.new
mv debian/changelog.new debian/changelog
fi
# LITE VERSION
if [ -f "../wkgtk-html2pdf-lite/debian/changelog" ]; then
echo "$CHANGELOG_HEADER_LITE" > ../wkgtk-html2pdf-lite/debian/changelog.new
echo "" >> ../wkgtk-html2pdf-lite/debian/changelog.new
echo " * Automated release: Version ${version}" >> ../wkgtk-html2pdf-lite/debian/changelog.new
echo "" >> ../wkgtk-html2pdf-lite/debian/changelog.new
echo "$CHANGELOG_FOOTER" >> ../wkgtk-html2pdf-lite/debian/changelog.new
echo "" >> ../wkgtk-html2pdf-lite/debian/changelog.new
cat ../wkgtk-html2pdf-lite/debian/changelog >> ../wkgtk-html2pdf-lite/debian/changelog.new
mv ../wkgtk-html2pdf-lite/debian/changelog.new ../wkgtk-html2pdf-lite/debian/changelog
fi
# For the GTK3 / WK4 version
SHLIBS_FILE4="debian/libwk2gtkpdf-4-${major}.shlibs"
echo "libwk2gtkpdf-4 ${major} libwk2gtkpdf-4-${major} (>= ${version})" > "$SHLIBS_FILE4"
echo "libwk2gtkpdf-4 ${major} libwk2gtkpdf-4-${major} (>= ${version})" > "../wkgtk-html2pdf-lite/$SHLIBS_FILE4"
# For the GTK4 / WK6 version
SHLIBS_FILE6="debian/libwk2gtkpdf-6-${major}.shlibs"
echo "libwk2gtkpdf-6 ${major} libwk2gtkpdf-6-${major} (>= ${version})" > "$SHLIBS_FILE6"
echo "libwk2gtkpdf-6 ${major} libwk2gtkpdf-6-${major} (>= ${version})" > "../wkgtk-html2pdf-lite/$SHLIBS_FILE6"
# Sanitise the debian files
sed -i 's/[[:space:]]*$//' debian/control debian/changelog debian/rules
# Stage everything (intentional)
git add .
# Commit if any staged changes exist
if git diff --cached --quiet; then
echo "No changes to commit (files unchanged)."
else
git commit -m "Bump version to ${version}"
fi
# Build tag name
tag="v${version}"
[[ -n "$suffix" ]] && tag="${tag}-$suffix"
# Prevent accidental duplicate tag (remove -f to be strict)
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
echo "Tag ${tag} already exists. Use -f to force or remove the existing tag first." >&2
exit 1
fi
# Create annotated tag
git tag -a "$tag" -m "Release $tag"
# Define the names exactly as the Debian Site Inspector expects
DEB_NAME="wkgtk-html2pdf"
DEB_ARCHIVE_NAME="${DEB_NAME}_${version}.orig.tar.gz"
DEB_ARCHIVE_NAME_LITE="${DEB_NAME}-lite_${version}.orig.tar.gz"
# Create the archive (with hyphen in prefix, underscore in filename)
git archive --format=tar.gz --prefix="${DEB_NAME}-${version}/" -o "../$DEB_ARCHIVE_NAME" "$tag"
tar cvf ../wkgtk-html2pdf-lite/$DEB_ARCHIVE_NAME_LITE --transform "s,^,${DEB_NAME}-lite-${version}/," src templates/A4-portrait-lite.css overflow-monitor.js wkgtk-html2pdf.1 50-wk2gtkpdf.rules wk2gtkpdf.pc.in xvfb.service LICENSE examples version.conf
echo "---------------------------------------------------"
echo "Version: $version"
echo "Tag created: $tag"
echo "Debian-ready Archive: $DEB_ARCHIVE_NAME (created in parent folder)"
echo "---------------------------------------------------"