deb-mock/.forgejo/workflows/build-deb.yml
robojerk 13c2dbc075
Some checks failed
Build and Publish Debian Package / build-deb (push) Failing after 1m23s
Build Deb-Mock Package / build (push) Successful in 54s
Test Deb-Mock Build / test (push) Failing after 55s
fix CI/CD workflows: direct git clone and version extraction from setup.py
2025-08-03 23:54:32 +00:00

133 lines
No EOL
4 KiB
YAML

name: Build and Publish Debian Package
on:
push:
branches: [ main, develop ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
jobs:
build-deb:
runs-on: ubuntu-latest
steps:
- name: Checkout code
run: |
git clone https://git.raines.xyz/robojerk/deb-mock.git /tmp/deb-mock
cp -r /tmp/deb-mock/* .
cp -r /tmp/deb-mock/.* . 2>/dev/null || true
- name: Set up Python
run: |
sudo apt update
sudo apt install -y python3.12 python3.12-venv python3-pip
- name: Install build dependencies
run: |
sudo apt update
sudo apt install -y build-essential devscripts debhelper dh-python python3-all python3-setuptools
sudo apt install -y sbuild schroot debootstrap
- name: Create deb-mock directories
run: |
sudo mkdir -p /var/lib/deb-mock/chroots /var/cache/deb-mock
sudo chown -R $USER:$USER /var/lib/deb-mock /var/cache/deb-mock
- name: Set up virtual environment
run: |
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
- name: Install dependencies
run: |
source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Install deb-mock in development mode
run: |
source venv/bin/activate
pip install -e .
- name: Run tests
run: |
source venv/bin/activate
python -m pytest tests/ -v --cov=deb_mock --cov-report=xml
- name: Build Debian package
run: |
# Get version from setup.py instead of importing module
VERSION=$(python3 -c "import re; print(re.search(r'version=[\"\']([^\"\']+)[\"\']', open('setup.py').read()).group(1))")
echo "Building version: $VERSION"
# Update changelog with current version
dch --newversion "$VERSION-1" --distribution unstable "Build from CI/CD"
# Build the package
dpkg-buildpackage -us -uc -b
# List built packages
ls -la ../*.deb ../*.changes ../*.dsc
- name: Upload build artifacts
run: |
echo "Debian package artifacts:"
ls -la ../*.deb ../*.changes ../*.dsc
echo "Package contents:"
dpkg -c ../deb-mock_*.deb || true
- name: Setup Debian repository
if: startsWith(github.ref, 'refs/tags/')
run: |
# Install reprepro for repository management
sudo apt install -y reprepro gnupg
# Create repository structure
mkdir -p debian-repo/conf
mkdir -p debian-repo/dists
mkdir -p debian-repo/pool
# Create repository configuration
cat > debian-repo/conf/distributions << EOF
Origin: Deb-Mock Repository
Label: Deb-Mock
Codename: unstable
Architectures: amd64 arm64 i386 all source
Components: main
Description: Deb-Mock Debian Package Repository
SignWith: default
EOF
# Create options file
cat > debian-repo/conf/options << EOF
verbose
basedir .
EOF
- name: Add package to repository
if: startsWith(github.ref, 'refs/tags/')
run: |
# Add the package to the repository
reprepro -b debian-repo includedeb unstable ../deb-mock_*.deb
# List repository contents
reprepro -b debian-repo list unstable
- name: Create repository archive
if: startsWith(github.ref, 'refs/tags/')
run: |
# Create a tarball of the repository
tar -czf deb-mock-repo.tar.gz debian-repo/
echo "Repository archive created:"
ls -la deb-mock-repo.tar.gz
- name: Upload repository artifacts
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "Repository artifacts:"
ls -la deb-mock-repo.tar.gz
echo "Repository structure:"
find debian-repo/ -type f | head -20