diff --git a/.github/workflows/build-rpm.yml b/.github/workflows/build-rpm.yml index 781d526cd1..0df5972c64 100644 --- a/.github/workflows/build-rpm.yml +++ b/.github/workflows/build-rpm.yml @@ -64,6 +64,10 @@ jobs: convert2rhel/__init__.py retention-days: 1 + - name: Trigger Manpage Generation + run: | + oamg/convert2rhel/.github/workflows/generate_manpage.yml@main + build_rpms: needs: - setup_version diff --git a/.github/workflows/generate_manpage.yml b/.github/workflows/generate_manpage.yml index 66e8e27a3c..7e0fba8002 100644 --- a/.github/workflows/generate_manpage.yml +++ b/.github/workflows/generate_manpage.yml @@ -12,22 +12,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 with: - python-version: 3.10.13 - - - name: Install dependencies - run: | - pip install argparse-manpage six pexpect - - - name: Install python3-rpm and python3-dnf package with apt-get - run: | - sudo apt-get update - sudo apt-get install -y python3-rpm python3-dnf + fetch-depth: 0 - - name: Generate Manpages + - name: Run version check script run: | chmod +x scripts/manpage_generation.sh bash scripts/manpage_generation.sh diff --git a/scripts/manpage_generation.sh b/scripts/manpage_generation.sh index ff3677c75e..95350b30a7 100755 --- a/scripts/manpage_generation.sh +++ b/scripts/manpage_generation.sh @@ -1,19 +1,18 @@ #!/bin/bash -# Directory to store the generated manpages -MANPAGE_DIR="man" +# Extract the current version from the spec file in the PR branch +CURRENT_VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) +echo "Current version from PR: $CURRENT_VER" -echo Generating manpages +# Fetch the version from the main branch +MAIN_VER=$(git show origin/main:packaging/convert2rhel.spec | grep -oP '^Version:\s+\K\S+') +echo "Version from main branch: $MAIN_VER" -VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) - -echo Generating for version $VER -# Generate a file with convert2rhel synopsis for argparse-manpage -/usr/bin/python -c 'from convert2rhel import toolopts; print("[synopsis]\n."+toolopts.CLI.usage())' > man/synopsis - -/usr/bin/python -m pip install argparse-manpage six pexpect - -# Generate the manpage using argparse-manpage -PYTHONPATH=. /usr/bin/python /home/runner/.local/bin/argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title="General Commands Manual" --description="Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux." --project-name "convert2rhel $VER" --prog="convert2rhel" --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" - -git status +# Compare versions +if [ "$CURRENT_VER" != "$MAIN_VER" ]; then + echo "Version has changed. Please update the manpages." + exit 1 +else + echo "Version is up-to-date." + exit 0 +fi