Skip to content

Build and Commit Slurm DEB Packages #4

Build and Commit Slurm DEB Packages

Build and Commit Slurm DEB Packages #4

name: Build and Commit Slurm DEB Packages
on:
workflow_dispatch:
inputs:
SLURM_VERSION_OVERRIDE:
description: 'Optional: Specific Slurm version to build (e.g., 24-11-5-1). Leave empty to use latest.'
required: false
default: ''
schedule:
- cron: '0 2 * * 1' # Every Monday at 2:00 AM UTC
jobs:
build-debs:
runs-on: ubuntu-24.04
container: ubuntu:26.04
outputs:
version: ${{ steps.vars.outputs.version }}
skip_build: ${{ steps.version-check.outputs.skip_build }}
steps:
- name: 🧰 Bootstrap Ubuntu 26.04 Container
run: |
set -e
apt-get update
apt-get install -y ca-certificates curl git jq
- name: 📦 Checkout Repository
uses: actions/checkout@v6
with:
# Fetch all history for all branches and tags
fetch-depth: 0
- name: 🎯 Determine Target Slurm Version
id: vars
run: |
set -e # Exit on error
# Use the manual dispatch input first, then the repo variable as a fallback
VERSION_OVERRIDE="${{ github.event.inputs.SLURM_VERSION_OVERRIDE || vars.SLURM_VERSION_OVERRIDE }}"
if [ -n "$VERSION_OVERRIDE" ] && [ "$VERSION_OVERRIDE" != "0" ]; then
echo "✅ Using specified version override: $VERSION_OVERRIDE"
VERSION="$VERSION_OVERRIDE"
else
echo "🔍 No version override set. Detecting latest stable version..."
# Fetch all tags from the SchedMD/slurm repo
TAGS=$(curl -s https://api.github.com/repos/SchedMD/slurm/tags | jq -r '.[].name')
# Filter for stable release tags (e.g., slurm-23-11-7-1) and get the latest
LATEST_TAG=$(echo "$TAGS" \
| grep -E '^slurm-[0-9]+-[0-9]+-[0-9]+-[0-9]+$' \
| sort -V \
| tail -n1)
if [ -z "$LATEST_TAG" ]; then
echo "❌ Could not determine the latest Slurm tag."
exit 1
fi
VERSION="${LATEST_TAG#slurm-}"
echo "🔬 Detected latest version: $VERSION"
fi
# Construct the tag name and download URL
TAG_NAME="slurm-${VERSION}"
TARBALL_URL="https://codeload.github.com/SchedMD/slurm/tar.gz/refs/tags/${TAG_NAME}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tarball_url=${TARBALL_URL}" >> $GITHUB_OUTPUT
- name: 🛑 Check if DEBs for this version already exist
id: version-check
run: |
version="${{ steps.vars.outputs.version }}"
debver="$(echo "$version" | sed 's/^\([0-9]*\)-\([0-9]*\)-\([0-9]*\)-\([0-9]*\)$/\1.\2.\3-\4/')"
debdir="$GITHUB_WORKSPACE/slurm-debs"
OS_CODENAME="u2604"
echo "🔍 Inputs:"
echo " Raw version = $version"
echo " Debian version = $debver"
echo " Search directory = $debdir"
echo " Search pattern = *_${debver}_*_${OS_CODENAME}.deb"
mkdir -p "$debdir"
echo "📂 Directory contents before search:"
ls -l "$debdir" || true
count=$(find "$debdir" -type f -name "*_${debver}_*_${OS_CODENAME}.deb" | wc -l || true)
if [ "$count" -gt 0 ]; then
echo "✅ DEBs for Slurm $version already exist. Skipping build."
echo "skip_build=true" >> $GITHUB_OUTPUT
else
echo "🚧 No existing DEBs for Slurm $version. Proceeding with build."
echo "skip_build=false" >> $GITHUB_OUTPUT
fi
- name: 🛠 Install Build Dependencies
if: steps.version-check.outputs.skip_build == 'false'
run: |
apt-get update
apt-get install -y \
devscripts equivs build-essential fakeroot debhelper curl jq git \
libpmix-dev libpmix2 libopenmpi-dev libopenmpi3 openmpi-bin libnvidia-ml-dev
- name: 📥 Download and Extract Slurm Source
if: steps.version-check.outputs.skip_build == 'false'
run: |
set -e
mkdir -p /tmp/slurm && cd /tmp/slurm
echo "Downloading from ${{ steps.vars.outputs.tarball_url }}"
curl -L "${{ steps.vars.outputs.tarball_url }}" -o slurm.tar.gz
tar -xzf slurm.tar.gz
src_dir=$(find . -maxdepth 1 -type d -name "slurm-*")
mv "$src_dir" slurm-src
- name: 📦 Build Slurm DEBs
if: steps.version-check.outputs.skip_build == 'false'
run: |
set -e
cd /tmp/slurm/slurm-src
# Use mk-build-deps to install dependencies from debian/control
mk-build-deps -ir --tool='apt-get -qq -y ' debian/control
# Build binary packages only, without signing
debuild -b -uc -us
- name: 📁 Rename and Move DEBs to Repo
if: steps.version-check.outputs.skip_build == 'false'
run: |
set -e
OS_CODENAME="u2604" # Change to ${{ matrix.os_codename }} if using a matrix
DEST_DIR="$GITHUB_WORKSPACE/slurm-debs"
mkdir -p "$DEST_DIR"
# Move all .deb files from the parent directory
for deb in /tmp/slurm/*.deb; do
base=$(basename "$deb" .deb)
mv "$deb" "$DEST_DIR/${base}_${OS_CODENAME}.deb"
done
echo "Moved DEBs to $DEST_DIR"
ls -l "$DEST_DIR"
- name: 📤 Commit and Push DEBs
if: steps.version-check.outputs.skip_build == 'false'
run: |
set -e
OS_CODENAME="u2604" # Change to ${{ matrix.os_codename }} if using a matrix
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add slurm-debs/
# Check if there are staged changes before committing
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "Add Slurm DEBs (v${{ steps.vars.outputs.version }}) for Ubuntu ${OS_CODENAME}"
git push
fi
env:
# Use a PAT if you have branch protection rules that GITHUB_TOKEN can't bypass
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}