Skip to content

Commit 72e9788

Browse files
committed
Package a CI binary whose version starts with a letter
Outside a tag the binary prints a bare commit hash as its version, such as 244d57b, and a Debian version must start with a digit: about six hashes in sixteen would have failed the native job. Such a version now gets 0~ in front, which sorts below every release; a release version is unchanged.
1 parent 4ea9837 commit 72e9788

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎.github/actions/deb-package/action.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
description: The native binary, for Linux on x86-64 or AArch64
1010
required: true
1111
version:
12-
description: The package version, which the binary must print as its own
12+
description: The version that the binary prints, which is the package version too (with 0~ in front when it does not start with a digit)
1313
required: true
1414
out-dir:
1515
description: The directory to write the package into
@@ -38,9 +38,15 @@ runs:
3838
COPYRIGHT: ${{ github.action_path }}/copyright
3939
run: |
4040
set -euo pipefail
41-
# Debian's rule for an upstream version without an epoch: a digit first, then these characters.
42-
if ! [[ $VERSION =~ ^[0-9][A-Za-z0-9.+~-]*$ ]]; then
43-
echo "Not a Debian package version: $VERSION" >&2
41+
# Debian's rule for an upstream version without an epoch: a digit first, then these characters. Outside
42+
# a tag the binary's version can be a bare commit hash, which may start with a letter: 0~ in front makes
43+
# it a version that sorts below every release.
44+
deb_version=$VERSION
45+
if ! [[ $deb_version =~ ^[0-9] ]]; then
46+
deb_version=0~$deb_version
47+
fi
48+
if ! [[ $deb_version =~ ^[0-9][A-Za-z0-9.+~-]*$ ]]; then
49+
echo "Not a Debian package version: $deb_version" >&2
4450
exit 1
4551
fi
4652
@@ -69,7 +75,7 @@ runs:
6975
mkdir "$root/DEBIAN"
7076
cat > "$root/DEBIAN/control" <<CONTROL
7177
Package: open-java-format
72-
Version: $VERSION
78+
Version: $deb_version
7379
Architecture: $arch
7480
Maintainer: Alexey Abashev <alexey@openjavaformat.dev>
7581
Installed-Size: $(du -sk --apparent-size "$root/usr" | cut -f 1)
@@ -85,7 +91,7 @@ runs:
8591
epoch=${SOURCE_DATE_EPOCH:-$(date +%s)}
8692
find "$root" -exec touch --no-dereference --date "@$epoch" {} +
8793
mkdir -p "$OUT_DIR"
88-
package=$OUT_DIR/open-java-format_${VERSION}_$arch.deb
94+
package=$OUT_DIR/open-java-format_${deb_version}_$arch.deb
8995
# xz, which every dpkg reads: dpkg-deb's default, zstd, needs dpkg 1.21.18 or later.
9096
SOURCE_DATE_EPOCH=$epoch dpkg-deb --root-owner-group -Zxz --build "$root" "$package"
9197
rm -rf "$root"

0 commit comments

Comments
 (0)