Skip to content

Commit

Permalink
Added in the check for the version for the manpage
Browse files Browse the repository at this point in the history
* Added in the the check to see if the manpages should be
  generated or not
* Changed the generate_manpage.yml file so that it sets up the
  action as needed, and removed some of the things not needed
  • Loading branch information
Andrew-ang9 committed Nov 4, 2024
1 parent 7be034f commit d7b5428
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/generate_manpage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 14 additions & 15 deletions scripts/manpage_generation.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d7b5428

Please sign in to comment.