Skip to content

Commit 739e502

Browse files
authored
Merge pull request #305 from padelsbach/wp-release-flow-fixes
Updates to Debian build scripts for release process
2 parents e41dcd0 + 98a48df commit 739e502

File tree

3 files changed

+129
-51
lines changed

3 files changed

+129
-51
lines changed

.github/workflows/build-wolfprovider.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ jobs:
5151
dh-exec \
5252
equivs \
5353
expect \
54-
xxd
54+
xxd \
55+
libdistro-info-perl
5556
5657
- name: Checkout wolfProvider
5758
uses: actions/checkout@v4

scripts/build-debian.sh

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,48 +29,17 @@ printf "Running build-debian.sh with WOLFSSL_ISFIPS=$WOLFSSL_ISFIPS and WOLFPROV
2929
REPO_ROOT=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}
3030
cd "$REPO_ROOT"
3131

32-
# Step 2: Determine latest upstream tag
33-
latest_tag=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n1)
34-
if [[ -z "$latest_tag" ]]; then
35-
echo "❌ Error: No tag found in format vX.Y.Z"
32+
# Step 2: Determine version from debian/changelog (no tag checks)
33+
if [[ ! -f debian/changelog ]]; then
34+
echo "❌ Error: debian/changelog not found."
35+
echo "👉 Run scripts/debian-changelog-update.sh to create/update the changelog first."
3636
exit 1
3737
fi
38-
latest_tag_commit=$(git rev-list -n 1 "$latest_tag")
39-
current_commit=$(git rev-parse HEAD)
4038

41-
UPSTREAM_VERSION="${latest_tag#v}" # e.g. 1.0.2
42-
43-
# Step 3: Determine Debian revision automatically
44-
if [[ -f debian/changelog ]]; then
45-
last_version=$(dpkg-parsechangelog --show-field Version)
46-
last_upstream="${last_version%%-*}" # strip Debian revision
47-
last_revision="${last_version##*-}" # get Debian revision number
48-
49-
if [[ "$last_upstream" == "$UPSTREAM_VERSION" ]]; then
50-
# Same upstream version → increment Debian revision
51-
DEB_REVISION=$((last_revision + 1))
52-
else
53-
# New upstream version → reset Debian revision to 1
54-
DEB_REVISION=1
55-
fi
56-
else
57-
DEB_REVISION=1
58-
fi
59-
60-
# Step 4: Compose full version string
61-
if [[ "$current_commit" == "$latest_tag_commit" ]]; then
62-
VERSION="${UPSTREAM_VERSION}-${DEB_REVISION}"
63-
echo "📌 On tag $latest_tag — using version: $VERSION"
64-
else
65-
echo "⚠️ Not on latest tagged commit ($latest_tag)"
66-
read -rp "❓ Continue building snapshot version? Type Y to confirm: " CONFIRM
67-
if [[ "$CONFIRM" != "Y" ]]; then
68-
echo "🚫 Aborting."
69-
exit 1
70-
fi
71-
VERSION="${UPSTREAM_VERSION}-${DEB_REVISION}"
72-
echo "📌 Snapshot build — using version: $VERSION"
73-
fi
39+
VERSION=$(dpkg-parsechangelog --show-field Version)
40+
UPSTREAM_VERSION="${VERSION%%-*}"
41+
current_commit=$(git rev-parse HEAD)
42+
echo "📌 Using version from changelog: $VERSION (upstream: $UPSTREAM_VERSION)"
7443

7544
TARBALL="${PKG_NAME}_${UPSTREAM_VERSION}.orig.tar.gz"
7645
TARBALL_PREFIX="${PKG_NAME}-${UPSTREAM_VERSION}"
@@ -92,17 +61,7 @@ fi
9261
echo "🧹 Cleaning untracked files..."
9362
git clean -fdx
9463

95-
# Step 8: Update debian/changelog
96-
echo "📝 Updating debian/changelog..."
97-
mkdir -p debian
98-
export DEBFULLNAME="${DEBFULLNAME:-WolfSSL Developer}"
99-
export DEBEMAIL="${DEBEMAIL:-support@wolfssl.com}"
100-
101-
if [[ -f debian/changelog ]]; then
102-
dch -v "$VERSION" --distribution unstable --urgency=medium "Release version $VERSION"
103-
else
104-
dch --create -v "$VERSION" --package "$PKG_NAME" --distribution unstable --urgency=medium "Initial release."
105-
fi
64+
# Step 8: Changelog updates handled by scripts/debian-changelog-update.sh
10665

10766
# Step 9: Create tarball
10867
if [[ -f "../$TARBALL" ]]; then

scripts/debian-changelog-update.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
#
3+
# Update or create debian/changelog using dch.
4+
# Usage:
5+
# scripts/debian-changelog-update.sh [--version VERSION] [--message MSG] [--distribution DIST] [--help]
6+
#
7+
# Behavior:
8+
# - If --version is provided, set that exact Debian version (e.g., 1.2.3-1).
9+
# - If not provided, auto-bump the Debian revision for the upstream version
10+
# found in the existing changelog; if no changelog exists, requires --version.
11+
# - If --distribution is not provided, defaults to "unstable".
12+
13+
set -euo pipefail
14+
15+
REPO_ROOT=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}
16+
cd "$REPO_ROOT"
17+
18+
PKG_NAME="libwolfprov"
19+
DEBFULLNAME="${DEBFULLNAME:-WolfSSL Developer}"
20+
DEBEMAIL="${DEBEMAIL:-support@wolfssl.com}"
21+
export DEBFULLNAME DEBEMAIL
22+
23+
explicit_version=""
24+
message="Release"
25+
distribution="unstable"
26+
27+
print_help() {
28+
cat <<EOF
29+
Update or create debian/changelog using dch.
30+
31+
Usage:
32+
scripts/debian-changelog-update.sh [--version VERSION] [--message MSG] [--distribution DIST]
33+
34+
Options:
35+
--version VERSION Set exact Debian version (e.g., 1.2.3-1). If omitted, auto-bump Debian revision.
36+
--message MSG Changelog message prefix. Default: "Release".
37+
--distribution DIST Target distribution for dch. Default: "unstable".
38+
--help Show this help and exit.
39+
40+
Examples:
41+
# Create or update changelog with explicit version for bookworm
42+
scripts/debian-changelog-update.sh --version 1.2.3-1 --distribution bookworm --message "Release"
43+
44+
# Auto-bump Debian revision in existing changelog for unstable
45+
scripts/debian-changelog-update.sh --message "Nightly build" --distribution unstable
46+
EOF
47+
}
48+
49+
while [[ $# -gt 0 ]]; do
50+
case "$1" in
51+
--version)
52+
explicit_version="$2"; shift 2 ;;
53+
--message)
54+
message="$2"; shift 2 ;;
55+
--distribution)
56+
distribution="$2"; shift 2 ;;
57+
--help)
58+
print_help; exit 0 ;;
59+
*)
60+
echo "Unknown argument: $1" >&2; exit 2 ;;
61+
esac
62+
done
63+
64+
mkdir -p debian
65+
66+
if [[ -n "$explicit_version" ]]; then
67+
# Validate explicit version for non-native packages: must include Debian revision (e.g., -1)
68+
format=""
69+
if [[ -f debian/source/format ]]; then
70+
format="$(head -n1 debian/source/format || true)"
71+
fi
72+
if [[ "$format" != "3.0 (native)" ]]; then
73+
# If there is no dash, assume missing Debian revision and provide a suggestion
74+
if [[ "$explicit_version" == "${explicit_version%%-*}" ]]; then
75+
echo "❌ Non-native package version must include a Debian revision (e.g., -1)." >&2
76+
echo " Provided: $explicit_version" >&2
77+
echo " Suggested: ${explicit_version}-1" >&2
78+
exit 2
79+
fi
80+
fi
81+
82+
if [[ -f debian/changelog ]]; then
83+
dch -v "$explicit_version" --distribution "$distribution" --urgency=medium "$message version $explicit_version"
84+
else
85+
dch --create -v "$explicit_version" --package "$PKG_NAME" \
86+
--distribution "$distribution" --urgency=medium "$message version $explicit_version"
87+
fi
88+
echo "Updated changelog to version $explicit_version"
89+
exit 0
90+
fi
91+
92+
# No explicit version provided. Attempt to auto-bump Debian revision.
93+
if [[ ! -f debian/changelog ]]; then
94+
echo "❌ debian/changelog does not exist. Provide --version to create it." >&2
95+
exit 1
96+
fi
97+
98+
current_version=$(dpkg-parsechangelog --show-field Version)
99+
upstream_version="${current_version%%-*}"
100+
current_rev="${current_version##*-}"
101+
102+
if [[ "$current_version" == "$upstream_version" ]]; then
103+
# No Debian revision part present; start at -1
104+
new_version="${upstream_version}-1"
105+
else
106+
if [[ "$current_rev" =~ ^[0-9]+$ ]]; then
107+
new_rev=$((current_rev + 1))
108+
else
109+
echo "❌ Could not parse Debian revision from version: $current_version" >&2
110+
exit 1
111+
fi
112+
new_version="${upstream_version}-${new_rev}"
113+
fi
114+
115+
dch -v "$new_version" --distribution "$distribution" --urgency=medium "$message version $new_version"
116+
echo "Bumped changelog version to $new_version"
117+
118+

0 commit comments

Comments
 (0)