Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ on:
description: OpenFastTrace version to package and release
required: true
type: string
default: 4.9.0
package_revision:
description: Debian package revision
required: true
default: "1"
type: string

jobs:
release:
Expand All @@ -23,6 +27,8 @@ jobs:
shell: bash
env:
VERSION: ${{ inputs.version }}
PACKAGE_REVISION: ${{ inputs.package_revision }}
PACKAGE_VERSION: ${{ inputs.version }}-${{ inputs.package_revision }}

steps:
- name: Checkout
Expand Down Expand Up @@ -75,32 +81,32 @@ jobs:
EOF

- name: Create source package
run: ./create-source-package.sh "$VERSION"
run: ./create-source-package.sh "$VERSION" "$PACKAGE_REVISION"

- name: Create binary package
run: ./create-binary-package.sh "$VERSION"
run: ./create-binary-package.sh "$VERSION" "$PACKAGE_REVISION"

- name: Generate SHA-256 checksums
run: |
(
cd out
sha256sum \
"openfasttrace_${VERSION}.orig.tar.gz" \
"openfasttrace_${VERSION}-1.debian.tar.xz" \
"openfasttrace_${VERSION}-1.dsc" \
"openfasttrace_${VERSION}-1_all.deb"
"openfasttrace_${PACKAGE_VERSION}.debian.tar.xz" \
"openfasttrace_${PACKAGE_VERSION}.dsc" \
"openfasttrace_${PACKAGE_VERSION}_all.deb"
) > out/SHA256SUMS

- name: Create GitHub release
run: |
gh release create "$VERSION" \
gh release create "$PACKAGE_VERSION" \
--target main \
--title "OpenFastTrace Debian package $VERSION" \
--title "$PACKAGE_VERSION: OpenFastTrace Debian Package" \
--generate-notes \
"out/openfasttrace_${VERSION}.orig.tar.gz" \
"out/openfasttrace_${VERSION}-1.debian.tar.xz" \
"out/openfasttrace_${VERSION}-1.dsc" \
"out/openfasttrace_${VERSION}-1_all.deb" \
"out/openfasttrace_${PACKAGE_VERSION}.debian.tar.xz" \
"out/openfasttrace_${PACKAGE_VERSION}.dsc" \
"out/openfasttrace_${PACKAGE_VERSION}_all.deb" \
out/SHA256SUMS
env:
GH_TOKEN: ${{ github.token }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This repository builds Debian packages for [OpenFastTrace](https://github.com/it
Pre-built source and binary packages are available from the [GitHub releases](https://github.com/itsallcode/openfasttrace-debian-package/releases). Install the binary package with its Java runtime dependency:

```sh
sudo apt install ./openfasttrace_<version>-1_all.deb
sudo apt install ./openfasttrace_<version>-<package-revision>_all.deb
```

Run OpenFastTrace with:
Expand All @@ -26,8 +26,8 @@ On Debian or a derived distribution, install the tools listed by the preconditio

```sh
./check-preconditions.sh
./create-source-package.sh <version>
./create-binary-package.sh <version>
./create-source-package.sh <version> [package-revision]
./create-binary-package.sh <version> [package-revision]
```

The resulting artifacts are placed in `out/`. The scripts download the specified OpenFastTrace source release, incorporate this repository's `debian/` packaging metadata, and build the package.
Expand Down
32 changes: 22 additions & 10 deletions create-binary-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,25 @@ validate_version() {
fi
}

validate_package_revision() {
local -r package_revision="$1"
if [[ ! "$package_revision" =~ ^[1-9][0-9]*$ ]]; then
echo "Error: Invalid Debian package revision '$package_revision'. Expected a positive integer." >&2
return 1
fi
}

# [impl->dsn~build-orchestration-scripts~1]
check_source_package_exists() {
local -r version="$1"
local -r dsc_file="$BUILD_DIR/openfasttrace_$version-1.dsc"
local -r package_revision="$2"
local -r dsc_file="$BUILD_DIR/openfasttrace_$version-$package_revision.dsc"
local -r orig_tarball="$BUILD_DIR/openfasttrace_$version.orig.tar.gz"
local -r debian_tarball="$BUILD_DIR/openfasttrace_$version-1.debian.tar.xz"
local -r debian_tarball="$BUILD_DIR/openfasttrace_$version-$package_revision.debian.tar.xz"

if [[ ! -f "$dsc_file" ]]; then
echo "Error: Source package control file not found at $dsc_file." >&2
echo "Please run ./create-source-package.sh $version first." >&2
echo "Please run ./create-source-package.sh $version $package_revision first." >&2
return 1
fi

Expand All @@ -48,7 +57,8 @@ check_source_package_exists() {
# [impl->dsn~build-orchestration-scripts~1]
extract_source_package() {
local -r version="$1"
local -r dsc_file="openfasttrace_${version}-1.dsc"
local -r package_revision="$2"
local -r dsc_file="openfasttrace_${version}-${package_revision}.dsc"
local -r build_subdir="$BUILD_DIR/openfasttrace-$version"

echo "Cleaning up any existing build directory $build_subdir..."
Expand All @@ -67,23 +77,25 @@ build_binary_package() {

# [impl->dsn~build-orchestration-scripts~1]
main() {
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <version>" >&2
if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "Usage: $0 <version> [package-revision]" >&2
exit 1
fi

local -r version="$1"
local -r package_revision="${2:-1}"
validate_version "$version"
validate_package_revision "$package_revision"

verify_preconditions
ensure_build_dir
check_source_package_exists "$version"
extract_source_package "$version"
check_source_package_exists "$version" "$package_revision"
extract_source_package "$version" "$package_revision"
build_binary_package "$version"

echo ""
echo "Binary package for version $version created successfully in $BUILD_DIR."
ls -l "$BUILD_DIR"/openfasttrace_"$version"-1_*.deb
echo "Binary package for version $version-$package_revision created successfully in $BUILD_DIR."
ls -l "$BUILD_DIR"/openfasttrace_"$version"-"$package_revision"_*.deb
}

main "$@"
30 changes: 21 additions & 9 deletions create-source-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ validate_version() {
fi
}

validate_package_revision() {
local -r package_revision="$1"
if [[ ! "$package_revision" =~ ^[1-9][0-9]*$ ]]; then
echo "Error: Invalid Debian package revision '$package_revision'. Expected a positive integer." >&2
return 1
fi
}

# [impl->dsn~source-fetching~1]
download_source() {
local -r version="$1"
Expand Down Expand Up @@ -91,8 +99,9 @@ extract_markdown_changes() {
# [impl->dsn~changelog-extraction~1]
apply_changelog_entries() {
local -r version="$1"
local -r entries_file="$2"
local -r debian_version="$version-1"
local -r package_revision="$2"
local -r entries_file="$3"
local -r debian_version="$version-$package_revision"

# Check if version already exists in changelog
if dpkg-parsechangelog -S Version | grep -q "^$debian_version$"; then
Expand Down Expand Up @@ -120,6 +129,7 @@ apply_changelog_entries() {
# [impl->dsn~changelog-extraction~1]
update_changelog() {
local -r version="$1"
local -r package_revision="$2"
local -r source_dir="$BUILD_DIR/openfasttrace-$version"
local -r changes_dir="$source_dir/doc/changes"
local -r change_file="$changes_dir/changes_$version.md"
Expand All @@ -128,19 +138,19 @@ update_changelog() {

if [[ ! -d "$changes_dir" ]]; then
echo "Warning: No changes directory found in source." >&2
dch --newversion "$version-1" --distribution unstable --force-distribution "New upstream release $version"
dch --newversion "$version-$package_revision" --distribution unstable --force-distribution "New upstream release $version"
return
fi

if [[ ! -f "$change_file" ]]; then
echo "Warning: No change file found for version $version at $change_file" >&2
dch --newversion "$version-1" --distribution unstable --force-distribution "New upstream release $version"
dch --newversion "$version-$package_revision" --distribution unstable --force-distribution "New upstream release $version"
return
fi

local -r temp_changelog_msg=$(mktemp)
extract_markdown_changes "$change_file" "$temp_changelog_msg"
apply_changelog_entries "$version" "$temp_changelog_msg"
apply_changelog_entries "$version" "$package_revision" "$temp_changelog_msg"
rm "$temp_changelog_msg"
}

Expand Down Expand Up @@ -170,24 +180,26 @@ cleanup_extraction() {

# [impl->dsn~build-orchestration-scripts~1]
main() {
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <version>" >&2
if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "Usage: $0 <version> [package-revision]" >&2
exit 1
fi

local -r version="$1"
local -r package_revision="${2:-1}"
validate_version "$version"
validate_package_revision "$package_revision"

verify_preconditions
ensure_build_dir
download_source "$version"
download_screenshots
extract_source "$BUILD_DIR/openfasttrace-$version.tar.gz" "$version"
update_changelog "$version"
update_changelog "$version" "$package_revision"
prepare_debian_source "$version"
cleanup_extraction "$version"

echo "Source package for version $version created successfully in $BUILD_DIR."
echo "Source package for version $version-$package_revision created successfully in $BUILD_DIR."
}

main "$@"
18 changes: 10 additions & 8 deletions test-packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ readonly BUILD_DIR="out"
# [itest->dsn~user-guide-manpage~1]
verify_output_files() {
local -r version="$1"
local -r package_revision="$2"
local -r expected_files=(
"$BUILD_DIR/openfasttrace_$version.orig.tar.gz"
"$BUILD_DIR/openfasttrace_$version-1.dsc"
"$BUILD_DIR/openfasttrace_$version-1.debian.tar.xz"
"$BUILD_DIR/openfasttrace_$version-$package_revision.dsc"
"$BUILD_DIR/openfasttrace_$version-$package_revision.debian.tar.xz"
)

echo "Verifying output files..."
Expand All @@ -30,7 +31,7 @@ verify_output_files() {
done

local deb_file=""
for f in "$BUILD_DIR"/openfasttrace_"$version"-1_*.deb; do
for f in "$BUILD_DIR"/openfasttrace_"$version"-"$package_revision"_*.deb; do
if [[ -e "$f" ]]; then
deb_file="$f"
break
Expand Down Expand Up @@ -141,19 +142,20 @@ validate_appstream() {
# [itest->dsn~finding-free-shellcheck~1]
main() {
local -r version="${1:-$DEFAULT_VERSION}"
echo "Starting integration test for version: $version"
local -r package_revision="${2:-1}"
echo "Starting integration test for version: $version-$package_revision"

echo "Step 1: Checking preconditions..."
./check-preconditions.sh

echo "Step 2: Creating source package..."
./create-source-package.sh "$version"
./create-source-package.sh "$version" "$package_revision"

echo "Step 3: Creating binary package..."
./create-binary-package.sh "$version"
./create-binary-package.sh "$version" "$package_revision"

echo "Step 4: Verifying output files..."
verify_output_files "$version"
verify_output_files "$version" "$package_revision"

echo "Step 5: Running shellcheck..."
run_shellcheck
Expand All @@ -162,7 +164,7 @@ main() {
validate_appstream "$version"

echo ""
echo "Integration test for OpenFastTrace version $version COMPLETED SUCCESSFULLY."
echo "Integration test for OpenFastTrace version $version-$package_revision COMPLETED SUCCESSFULLY."
}

main "$@"