deb-bootupd/.forgejo/workflows/build-artifacts.yml
Workflow config file is invalid. Please check your config file: yaml: line 62: could not find expected ':'
robojerk 2b9f885009
Some checks failed
Simple Build & Upload / build (push) Has been cancelled
Add Node.js to workflows for Forgejo Actions compatibility
- Install nodejs and npm in both workflows
- Required for Forgejo Actions artifact upload functionality
- This should resolve the 'node: executable file not found' error
- Both workflows now have all necessary dependencies
2025-08-10 00:52:14 -07:00

262 lines
9.2 KiB
YAML

name: Build deb-bootupd Artifacts
# ⚠️ IMPORTANT: Each repository needs its own ACCESS_TOKEN secret!
#
# To set up this workflow in a new repository:
# 1. Go to repository settings: https://git.raines.xyz/OWNER/REPO/settings
# 2. Find "Secrets" or "Repository secrets" section
# 3. Add new secret:
# - Name: ACCESS_TOKEN
# - Value: Your Personal Access Token with repo and write:packages permissions
# 4. The token needs these scopes:
# - repo (Full control of private repositories)
# - write:packages (Write packages)
# - read:packages (Read packages)
#
# This workflow will fail with "ACCESS_TOKEN is not set" if the secret is missing.
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
env:
DEBIAN_VERSION: "13 (Trixie)"
RUST_VERSION: "1.89.0"
jobs:
build-artifacts:
name: Build deb-bootupd Artifacts
runs-on: ubuntu-latest
container:
# Use complete Rust image with all components pre-installed
# This avoids the "whack-a-mole" of adding components one by one
image: rust:1.89
steps:
- name: Setup build environment
shell: bash
run: |
apt update -y
apt install -y git curl pkg-config build-essential gnupg
# Rust 1.89.0 is already installed in rust:1.89-debian-trixie-slim
# No need for rustup or toolchain management!
echo "✅ Using pre-installed Rust from official image:"
rustc --version
cargo --version
# Verify Rust version meets requirements (need 1.84.1+)
RUST_VERSION=$(rustc --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1)
echo "Rust version: $RUST_VERSION"
if [ "$(printf '%s\n' "1.84.1" "$RUST_VERSION" | sort -V | head -n1)" != "1.84.1" ]; then
echo "❌ Rust version $RUST_VERSION is too old, need 1.84.1+"
exit 1
else
echo "✅ Rust version $RUST_VERSION meets requirement (1.84.1+)"
fi
# Install additional build dependencies
apt install -y libssl-dev libsystemd-dev file pkg-config build-essential zip nodejs npm
# Install required Rust components
echo "Installing Rust components..."
rustup component add clippy
rustup component add rustfmt
rustup component add rust-src # For better error messages
rustup component add rust-analysis # For IDE support
echo "Available Rust components:"
rustup component list --installed
- name: Checkout repository manually
run: |
# Clone the repository manually instead of using actions/checkout
git clone https://git.raines.xyz/robojerk/deb-bootupd.git /tmp/deb-bootupd
cd /tmp/deb-bootupd
# Show repository info
echo "Repository: $(git remote get-url origin)"
echo "Branch: $(git branch --show-current)"
echo "Commit: $(git rev-parse --short HEAD)"
echo "Date: $(git log -1 --format=%cd)"
- name: Build Rust project
run: |
cd /tmp/deb-bootupd
# Show project structure
echo "Project structure:"
ls -la
# Check Cargo.toml
echo "Cargo.toml contents:"
cat Cargo.toml
# Check Cargo.lock version
echo "Cargo.lock version:"
head -n 1 Cargo.lock
# Rust 1.89.0 should handle any Cargo.lock version without issues
echo "Using Rust 1.89.0 - should handle all Cargo.lock versions"
# Build in release mode
echo "Building deb-bootupd in release mode..."
cargo build --release
# Verify binaries were created
echo "Build artifacts:"
ls -la target/release/
# Show binary information
if [ -f target/release/bootupd ]; then
echo "bootupd binary info:"
file target/release/bootupd
ldd target/release/bootupd || echo "Static binary or no dynamic dependencies"
fi
- name: Run tests
run: |
cd /tmp/deb-bootupd
echo "Running tests..."
cargo test --release
echo "Running clippy..."
cargo clippy --release
echo "Checking formatting..."
cargo fmt --check
- name: Create build artifacts
run: |
cd /tmp/deb-bootupd
# Create artifacts directory
mkdir -p build-artifacts
# Copy compiled binaries
cp target/release/bootupd build-artifacts/
cp target/release/bootupctl build-artifacts/ 2>/dev/null || echo "bootupctl not found (may be symlink)"
# Copy source code for reference
cp -r src/ build-artifacts/
cp Cargo.toml Cargo.lock build-artifacts/
# Copy Debian packaging files
cp -r debian/ build-artifacts/ 2>/dev/null || echo "debian/ directory not found"
cp -r systemd/ build-artifacts/ 2>/dev/null || echo "systemd/ directory not found"
# Create build info file
cat > build-artifacts/BUILD_INFO.txt << EOF
deb-bootupd Build Information
=============================
Build Date: $(date)
Container Image: rust:1.89
Debian Version: ${DEBIAN_VERSION}
Rust Version: $(rustc --version)
Cargo Version: $(cargo --version)
Git Commit: $(git rev-parse --short HEAD)
Git Branch: $(git branch --show-current)
Build Type: Release
EOF
# Show artifacts
echo "Build artifacts created:"
ls -la build-artifacts/
echo ""
echo "Build info:"
cat build-artifacts/BUILD_INFO.txt
- name: Upload artifacts to Forgejo
env:
USER: robojerk
TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_URL: "git.raines.xyz"
run: |
cd /tmp/deb-bootupd
# Create zip archive of artifacts
artifact_name="deb-bootupd-artifacts-$(git rev-parse --short HEAD).zip"
zip -r "$artifact_name" build-artifacts/
echo "Created artifact archive: $artifact_name"
ls -la "$artifact_name"
# Upload to Forgejo generic package registry
echo "Uploading artifacts to Forgejo Package Registry..."
# Use the same upload pattern as bootc-deb
path="api/packages/robojerk/generic/deb-bootupd/$(git rev-parse --short HEAD)"
upload_url="https://${BASE_URL}/${path}/${artifact_name}"
echo "Upload URL: $upload_url"
# Upload with proper authentication
http_code=$(curl -s -o /dev/null -w "%{http_code}" \
--user "${USER}:${TOKEN}" \
--upload-file "$artifact_name" \
"$upload_url")
echo "HTTP Response Code: $http_code"
if [ "$http_code" = "201" ]; then
echo "✅ Artifacts uploaded successfully to Forgejo Package Registry"
elif [ "$http_code" = "409" ]; then
echo "➡️ INFO: Artifacts already exist (HTTP 409 Conflict)"
else
echo "❌ Upload failed with HTTP $http_code"
# Show verbose output for debugging
curl -v -i --user "${USER}:${TOKEN}" \
--upload-file "$artifact_name" \
"$upload_url" 2>&1
exit 1
fi
- name: Create release assets
run: |
cd /tmp/deb-bootupd
mkdir -p release-assets
cp "$artifact_name" release-assets/ 2>/dev/null || echo "No artifact archive found"
# Create a summary file
cat > release-assets/BUILD_SUMMARY.txt << EOF
deb-bootupd Build Summary
=========================
Build Date: $(date)
Debian Version: ${DEBIAN_VERSION}
Container Image: rust:1.89
Rust Version: $(rustc --version)
Git Commit: $(git rev-parse --short HEAD)
Git Branch: $(git branch --show-current)
Built Artifacts:
- Rust binaries (release mode)
- Source code
- Debian packaging files
- Systemd service files
Artifact Archive: $artifact_name
EOF
echo "Release assets created:"
ls -la release-assets/
- name: Success Summary
run: |
echo "=== Build Summary ==="
echo "✅ deb-bootupd compiled successfully in release mode"
echo "✅ All tests passed"
echo "✅ Code formatting and linting passed"
echo "✅ Build artifacts created and uploaded to Forgejo"
echo ""
echo "📦 Artifacts available at:"
echo " https://git.raines.xyz/robojerk/deb-bootupd/packages"
echo ""
echo "🎯 Next steps:"
echo " - Verify artifacts appear in repository packages page"
echo " - Test binaries on Ubuntu Noble systems"
echo " - Consider building .deb packages for distribution"