diff --git a/.github/workflows/build_pkg.yml b/.github/workflows/build_pkg.yml index 8f60a10..ae6661b 100644 --- a/.github/workflows/build_pkg.yml +++ b/.github/workflows/build_pkg.yml @@ -38,6 +38,12 @@ on: message: type: string default: "" + tag_suffix: + type: string + default: "" + tag_mangel: + type: string + default: "" jobs: source: name: source package diff --git a/container/bin/build_source b/container/bin/build_source index 2289de0..950222f 100755 --- a/container/bin/build_source +++ b/container/bin/build_source @@ -20,6 +20,8 @@ main() ( debian_source="$(yq -r '.jobs.build_pkg.with.debian_source // "'$debian_source'"' < "$inputs_file")" build_options="terse $(yq -r '.jobs.build_pkg.with.build_options // ""' < "$inputs_file")" build_profiles="$(yq -r '.jobs.build_pkg.with.build_profiles // ""' < "$inputs_file")" + tag_suffix="$(yq -r '.jobs.build_pkg.with.tag_suffix // ""' < "$inputs_file")" + tag_mangle="$(yq -r '.jobs.build_pkg.with.tag_mangle // ""' < "$inputs_file")" # Define Build Options export DEB_BUILD_OPTIONS="$build_options" @@ -144,7 +146,15 @@ apply_patches() ( distribution="$(yq -r '.jobs.build_pkg.with.distribution // "'"$distribution"'"' < "$inputs_file")" message="$(yq -r '.jobs.build_pkg.with.message // "'"$message"'"' < "$inputs_file")" - DEBEMAIL="$email" DEBFULLNAME="$maintainer" dch --newversion "$(get_version)" --distribution "$distribution" --force-distribution -- "$message" + if [ -f debian/changelog ]; then + DEBEMAIL="$email" DEBFULLNAME="$maintainer" dch \ + --newversion "$(get_version)" --distribution "$distribution" \ + --force-distribution -- "$message" + else + DEBEMAIL="$email" DEBFULLNAME="$maintainer" EDITOR=true dch --create --package $name \ + --newversion "$(get_version)" --distribution "$distribution" \ + --force-distribution -- "$message" + fi if [ -x "$1/exec.post" ]; then SOURCE="$source" "$1/exec.post" @@ -152,7 +162,7 @@ apply_patches() ( ) get_sources() ( - local source=$1 + #local source=$1 # What kind of source do we have? if [[ "$source" = "git+"* ]]; then @@ -164,6 +174,12 @@ get_sources() ( fi ) +get_upstream-version() ( + IFS='#' read -r url ref <<< "${source#git+}" + git ls-remote --tags --refs $url "$tag_suffix"* | awk -F/ '{ print $3 }' | \ + grep -Ev "$tag_mangle" | tail -1 | sed -e s/"$tag_suffix"// +) + get_version() ( local version=$PACKAGE_VERSION @@ -171,7 +187,11 @@ get_version() ( # the version of the upstream package and add # the git tag to it. if [ -z "$version" ]; then - package_version=$(dpkg-parsechangelog --show-field Version) + if [ -f /input/debian/changelog ]; then + package_version=$(dpkg-parsechangelog --show-field Version) + else + package_version=$(get_upstream-version) + fi commit_hash=$(git -C /input rev-parse HEAD) # No version has been provided. Check if there is already a Garden Linux version 0