From 345fce2218cf657c5e90680368bac5bdb48149f6 Mon Sep 17 00:00:00 2001 From: robojerk Date: Mon, 4 Aug 2025 02:30:37 +0000 Subject: [PATCH] fix CI/CD: simplify build-debian.yml workflow and remove duplicate release.yml --- .forgejo/workflows/build-debian.yml | 54 +++++++++----------------- .forgejo/workflows/release.yml | 60 ----------------------------- 2 files changed, 18 insertions(+), 96 deletions(-) delete mode 100644 .forgejo/workflows/release.yml diff --git a/.forgejo/workflows/build-debian.yml b/.forgejo/workflows/build-debian.yml index 1a150f6..168d1e5 100644 --- a/.forgejo/workflows/build-debian.yml +++ b/.forgejo/workflows/build-debian.yml @@ -61,51 +61,33 @@ jobs: - name: Build Debian package run: | - # Get version from setup.py instead of importing module + echo "=== Building Debian Package ===" + + # Get version from setup.py 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" + # Check if we need to update changelog + CURRENT_CHANGELOG_VERSION=$(head -1 debian/changelog | sed 's/mock (\([^-]*\)-[^)]*).*/\1/') + echo "Current changelog version: $CURRENT_CHANGELOG_VERSION" + echo "Target version: $VERSION" + + if [ "$CURRENT_CHANGELOG_VERSION" != "$VERSION" ]; then + echo "Updating changelog to version $VERSION" + dch --newversion "$VERSION-1" --distribution unstable "Build from CI/CD" + else + echo "Changelog already at correct version" + fi # Build the package + echo "Building package with dpkg-buildpackage..." dpkg-buildpackage -us -uc -b - # List built packages (handle missing .dsc file) + # List built packages echo "Built packages:" - ls -la ../mock_*.deb ../mock_*.changes 2>/dev/null || true + ls -la ../mock_*.deb ../mock_*.changes 2>/dev/null || echo "No packages found" ls -la ../mock_*.dsc 2>/dev/null || echo "No .dsc file (binary-only package)" - - name: Upload build artifacts - run: | - echo "Debian package artifacts:" - ls -la ../mock_*.deb ../mock_*.changes 2>/dev/null || true - ls -la ../mock_*.dsc 2>/dev/null || echo "No .dsc file (binary-only package)" - echo "Package contents:" - dpkg -c ../mock_*.deb || true - - - name: Create release assets - run: | - mkdir -p release-assets - cp ../mock_*.deb release-assets/ 2>/dev/null || echo "No .deb files found" - cp ../mock_*.changes release-assets/ 2>/dev/null || echo "No .changes files found" - - # Create a summary file - echo "Mock Package Build Summary" > release-assets/BUILD_SUMMARY.txt - echo "==========================" >> release-assets/BUILD_SUMMARY.txt - echo "Build Date: $(date)" >> release-assets/BUILD_SUMMARY.txt - echo "Package: mock" >> release-assets/BUILD_SUMMARY.txt - echo "Version: $VERSION" >> release-assets/BUILD_SUMMARY.txt - echo "" >> release-assets/BUILD_SUMMARY.txt - echo "Built Packages:" >> release-assets/BUILD_SUMMARY.txt - ls -la release-assets/*.deb 2>/dev/null || echo "No packages found" >> release-assets/BUILD_SUMMARY.txt - echo "" >> release-assets/BUILD_SUMMARY.txt - echo "Changes Files:" >> release-assets/BUILD_SUMMARY.txt - ls -la release-assets/*.changes 2>/dev/null || echo "No changes files found" >> release-assets/BUILD_SUMMARY.txt - - echo "Release assets created:" - ls -la release-assets/ - - name: Upload to Forgejo Debian Package Registry if: startsWith(github.ref, 'refs/tags/') run: | @@ -161,7 +143,7 @@ jobs: echo "✅ Package automatically assigned to repository by Forgejo" echo "" echo "📦 Package should now be available at:" - echo " https://git.raines.xyz/robojerk/deb-mock/packages" + echo " https://git.raines.xyz/robojerk/-/packages" echo "" echo "🎯 Next steps:" echo " - Verify package appears in repository packages page" diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml deleted file mode 100644 index 6312482..0000000 --- a/.forgejo/workflows/release.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Release Deb-Mock - -on: - push: - tags: - - 'v*' - -jobs: - release: - 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 system dependencies - run: | - sudo apt install -y sbuild schroot debootstrap - - - name: Set up virtual environment - run: | - python3 -m venv venv - source venv/bin/activate - pip install --upgrade pip setuptools wheel twine - - - name: Install dependencies - run: | - source venv/bin/activate - pip install -r requirements.txt - pip install -r requirements-dev.txt - - - name: Run tests - run: | - source venv/bin/activate - python -m pytest tests/ -v - - - name: Build package - run: | - source venv/bin/activate - python setup.py sdist bdist_wheel - - - name: Check package - run: | - source venv/bin/activate - twine check dist/* - - - name: List release artifacts - run: | - echo "Release artifacts created:" - ls -la dist/ - echo "Tag: ${{ github.ref_name }}" - echo "Repository: ${{ github.repository }}" \ No newline at end of file