From 1617212c5b0948174155ece4a9d0584764bd7dac Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 9 Dec 2023 20:25:51 +0200 Subject: [PATCH] CI: add scripts/check_debian_changelog.sh lint Check if latest version in debian/changelog matches the version in meli/Cargo.toml. Signed-off-by: Manos Pitsidianakis --- .gitea/workflows/manifest_lints.yaml | 6 +++ debian/control | 2 +- debian/copyright | 4 +- scripts/check_debian_changelog.sh | 60 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100755 scripts/check_debian_changelog.sh diff --git a/.gitea/workflows/manifest_lints.yaml b/.gitea/workflows/manifest_lints.yaml index a038acf7..689d0deb 100644 --- a/.gitea/workflows/manifest_lints.yaml +++ b/.gitea/workflows/manifest_lints.yaml @@ -45,6 +45,8 @@ jobs: os: ubuntu-latest rust: stable target: x86_64-unknown-linux-gnu + run: + working-directory: ./scripts steps: - uses: https://github.com/actions/checkout@v2 - id: os-deps @@ -95,3 +97,7 @@ jobs: cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace fuzz cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace tools cargo-sort --check --check-format --grouped --order package,bin,lib,dependencies,features,build-dependencies,dev-dependencies,workspace --workspace + - name: Check debian/changelog is up-to-date. + if: success() || failure() + run: | + ./scripts/check_debian_changelog.sh diff --git a/debian/control b/debian/control index a3f33f3a..70e8867e 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: Manos Pitsidianakis Build-Depends: debhelper (>=11~), mandoc (>=1.14.4-1), quilt, libsqlite3-dev Standards-Version: 4.1.4 -Homepage: https://meli.delivery +Homepage: https://meliemail.org Package: meli Architecture: any diff --git a/debian/copyright b/debian/copyright index cefe2a3d..89697eb3 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,11 +1,11 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: meli -Source: +Source: # # Please double check copyright with the licensecheck(1) command. Files: * -Copyright: 2017-2020 Manos Pitsidianakis +Copyright: 2017-2023 Manos Pitsidianakis License: GPL-3.0+ #---------------------------------------------------------------------------- # License file: COPYING diff --git a/scripts/check_debian_changelog.sh b/scripts/check_debian_changelog.sh new file mode 100755 index 00000000..c5c1c52e --- /dev/null +++ b/scripts/check_debian_changelog.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# SPDX-License-Identifier: EUPL-1.2 + +usage() { printf "Check if latest version in debian/changelog matches the version in meli/Cargo.toml.\n\nUsage: %s [-q ] [-i]\n\n-q\tQuiet; no output.\n-i\tNon-interactive mode.\n" "${0}" 1>&2; exit 1; } + +while getopts "qi" o; do + case "${o}" in + q) + QUIET="true" + ;; + i) + NONINTERACTIVE="true" + ;; + *) + usage + ;; + esac +done +shift $((OPTIND-1)) + +VERSION=$(grep -m1 version meli/Cargo.toml | head -n1 | cut -d'"' -f 2 | head -n1) +DEBIAN_CHANGELOG_VERSION=$(grep -m1 meli debian/changelog | head -n1 | cut -d'(' -f 2 | cut -d')' -f 1 | sed -e 's/\-[0-9]$//') + + +if [ "${VERSION}" == "${DEBIAN_CHANGELOG_VERSION}" ]; then + if [ -z "${QUIET}" ]; then + printf "Versions match: %s\n" "${VERSION}" + fi + exit 0; +fi + +if [ -z "${QUIET}" ]; then + printf "Version in meli/Cargo.toml, %s, is not the same as the latest version in debian/changelog file, which is %s\n\n" "${VERSION}" "${DEBIAN_CHANGELOG_VERSION}" + echo "Please update debian/changelog with the following diff:" + author=$(grep -m1 authors meli/Cargo.toml | head -n1 | cut -d'"' -f 2 | head -n1) + now=$(date -u +"%a, %d %b %Y %T +0000") + prepend_value=$(cat <