Add build versioning and Forgejo Debian Registry publishing

- Add build number and commit hash to package version (0.1.0+build{N}.{commit})
- Focus CI artifacts on .deb files (your priority)
- Auto-publish packages to Forgejo Debian Registry
- Handle version conflicts and provide clear feedback
- Show detailed package information in CI logs
- Enable traceability from package back to specific build/commit
- Ready for production package distribution
This commit is contained in:
joe 2025-08-13 23:12:02 -07:00
parent d7f30c2d54
commit 7d4a2e8139

View file

@ -90,6 +90,15 @@ jobs:
run: |
echo "Building Debian package..."
# Get build information for versioning
BUILD_NUMBER="${GITHUB_RUN_NUMBER:-$(date +%s)}"
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_VERSION="0.1.0+build${BUILD_NUMBER}.${COMMIT_HASH}"
echo "Build Version: $BUILD_VERSION"
echo "Build Number: $BUILD_NUMBER"
echo "Commit Hash: $COMMIT_HASH"
# Check if we have the necessary files
if [ -f "Cargo.toml" ] && [ -d "debian" ]; then
echo "✅ Found Cargo.toml and debian directory"
@ -105,18 +114,18 @@ jobs:
cp target/release/apt-ostree debian/apt-ostree/usr/bin/
chmod +x debian/apt-ostree/usr/bin/apt-ostree
# Create control file
# Create control file with build version
mkdir -p debian/apt-ostree/DEBIAN
echo "Package: apt-ostree" > debian/apt-ostree/DEBIAN/control
echo "Version: 0.1.0" >> debian/apt-ostree/DEBIAN/control
echo "Version: $BUILD_VERSION" >> debian/apt-ostree/DEBIAN/control
echo "Architecture: amd64" >> debian/apt-ostree/DEBIAN/control
echo "Maintainer: Robojerk <robojerk@example.com>" >> debian/apt-ostree/DEBIAN/control
echo "Description: APT-OSTree package for Debian-based OSTree systems" >> debian/apt-ostree/DEBIAN/control
echo " A tool for managing OSTree deployments with APT package management." >> debian/apt-ostree/DEBIAN/control
echo " Provides atomic updates and rollback capabilities for Debian systems." >> debian/apt-ostree/DEBIAN/control
# Build package
dpkg-deb --build debian/apt-ostree apt-ostree_0.1.0_amd64.deb
# Build package with build version
dpkg-deb --build debian/apt-ostree "apt-ostree_${BUILD_VERSION}_amd64.deb"
fi
# Check if package was created (dpkg-buildpackage puts them in parent directory)
@ -226,12 +235,26 @@ jobs:
# Create artifacts directory
mkdir -p artifacts
# Copy all built packages
# Copy all built packages (focus on .deb files)
if ls *.deb >/dev/null 2>&1; then
echo "Copying Debian packages to artifacts directory..."
echo "📦 Copying Debian packages to artifacts directory..."
cp *.deb artifacts/
echo "Packages copied:"
echo "Packages copied:"
ls -la artifacts/*.deb
# Show package details
echo ""
echo "📋 Package Details:"
for pkg in artifacts/*.deb; do
PKG_NAME=$(dpkg-deb -f "$pkg" Package 2>/dev/null || echo "Unknown")
PKG_VERSION=$(dpkg-deb -f "$pkg" Version 2>/dev/null || echo "Unknown")
PKG_ARCH=$(dpkg-deb -f "$pkg" Architecture 2>/dev/null || echo "Unknown")
PKG_SIZE=$(du -h "$pkg" | cut -f1)
echo " 🎯 $PKG_NAME ($PKG_VERSION) [$PKG_ARCH] - $PKG_SIZE"
done
else
echo "❌ No .deb packages found!"
exit 1
fi
# Copy build summary
@ -346,6 +369,90 @@ jobs:
echo "🎉 BUILD COMPLETE! Your artifacts are ready for download!"
echo "📁 Check the CI logs above for the downloadable archive files."
- name: Publish to Forgejo Debian Registry
run: |
echo "Publishing .deb packages to Forgejo Debian Registry..."
# Check if we have .deb files
if ! ls *.deb >/dev/null 2>&1; then
echo "❌ No .deb files found to publish"
exit 1
fi
# Get build info for registry
BUILD_NUMBER="${GITHUB_RUN_NUMBER:-$(date +%s)}"
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
echo "Publishing packages for build $BUILD_NUMBER (commit $COMMIT_HASH)"
# Forgejo Debian Registry configuration
FORGEJO_OWNER="particle-os" # Your organization/username
FORGEJO_DISTRIBUTION="trixie" # Debian distribution
FORGEJO_COMPONENT="main" # Package component
# Publish each .deb file
for deb_file in *.deb; do
echo "📦 Publishing $deb_file..."
# Extract package info
PKG_NAME=$(dpkg-deb -f "$deb_file" Package 2>/dev/null || echo "apt-ostree")
PKG_VERSION=$(dpkg-deb -f "$deb_file" Version 2>/dev/null || echo "unknown")
PKG_ARCH=$(dpkg-deb -f "$deb_file" Architecture 2>/dev/null || echo "amd64")
echo " Package: $PKG_NAME"
echo " Version: $PKG_VERSION"
echo " Architecture: $PKG_ARCH"
# Forgejo Debian Registry upload URL
UPLOAD_URL="https://git.raines.xyz/api/packages/${FORGEJO_OWNER}/debian/pool/${FORGEJO_DISTRIBUTION}/${FORGEJO_COMPONENT}/upload"
echo " Upload URL: $UPLOAD_URL"
# Upload to Forgejo Debian Registry
# Note: This requires authentication - you'll need to set up secrets
if [ -n "$FORGEJO_TOKEN" ]; then
echo " 🔐 Using authentication token..."
UPLOAD_RESULT=$(curl -s -w "%{http_code}" \
--user "${FORGEJO_OWNER}:${FORGEJO_TOKEN}" \
--upload-file "$deb_file" \
"$UPLOAD_URL" 2>/dev/null)
HTTP_CODE="${UPLOAD_RESULT: -3}"
RESPONSE_BODY="${UPLOAD_RESULT%???}"
case $HTTP_CODE in
201)
echo " ✅ Successfully published to Forgejo Debian Registry!"
echo " 📥 Install with: apt install $PKG_NAME"
;;
409)
echo " ⚠️ Package already exists (version conflict)"
echo " 💡 Consider deleting old version first"
;;
400)
echo " ❌ Bad request - package validation failed"
;;
*)
echo " ❌ Upload failed with HTTP $HTTP_CODE"
echo " Response: $RESPONSE_BODY"
;;
esac
else
echo " ⚠️ No FORGEJO_TOKEN set - skipping upload"
echo " 💡 Set FORGEJO_TOKEN secret to enable automatic publishing"
echo " 📋 Manual upload command:"
echo " curl --user your_username:your_token \\"
echo " --upload-file $deb_file \\"
echo " $UPLOAD_URL"
fi
echo ""
done
echo "🎯 Debian package publishing complete!"
echo "📦 Packages are now available in Forgejo Debian Registry"
echo "🔧 To install: apt install apt-ostree"
# Security check
security:
name: Security Audit