name: Publish to crates.io
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
env:
CARGO_TERM_COLOR: always
jobs:
verify-and-test:
name: Verify and Test
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install MPI
run: |
sudo apt-get update
sudo apt-get install -y mpich libmpich-dev pkg-config
- name: Hotfix MPICH on Ubuntu Noble
run: |
# Workaround for broken MPICH 4.2.0 package in Ubuntu 24.04 LTS (Noble)
# See: https://bugs.launchpad.net/ubuntu/+source/mpich/+bug/2072338
ARCH=$(dpkg --print-architecture)
REPO=https://archive.ubuntu.com/ubuntu
LIBUCX=libucx0_1.18.1+ds-2_${ARCH}.deb
LIBMPICH=libmpich12_4.2.1-5_${ARCH}.deb
curl -sSOf ${REPO}/pool/universe/u/ucx/${LIBUCX}
curl -sSOf ${REPO}/pool/universe/m/mpich/${LIBMPICH}
TMPDIR=$(mktemp -d)
dpkg-deb -x ${LIBUCX} ${TMPDIR}
dpkg-deb -x ${LIBMPICH} ${TMPDIR}
LIBDIR=/usr/lib/$(arch)-linux-gnu
sudo cp -a ${TMPDIR}${LIBDIR}/ucx ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0 ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12 ${LIBDIR}
sudo ldconfig
rm -rf ${TMPDIR} ${LIBUCX} ${LIBMPICH}
echo "MPICH hotfix applied successfully"
- name: Extract version from tag
id: tag_version
run: |
TAG="${GITHUB_REF#refs/tags/v}"
echo "version=$TAG" >> $GITHUB_OUTPUT
- name: Extract version from Cargo.toml
id: cargo_version
run: |
VERSION=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Verify versions match
run: |
if [ "${{ steps.tag_version.outputs.version }}" != "${{ steps.cargo_version.outputs.version }}" ]; then
echo "❌ Version mismatch!"
echo "Tag version: ${{ steps.tag_version.outputs.version }}"
echo "Cargo.toml version: ${{ steps.cargo_version.outputs.version }}"
exit 1
fi
echo "✅ Versions match: ${{ steps.cargo_version.outputs.version }}"
- name: Run cargo-audit
uses: actions-rust-lang/audit@v1
with:
denyWarnings: false
- name: Run tests
run: cargo test --all-features --verbose
- name: Build examples
run: cargo build --examples --release
- name: Run examples
run: |
for example in hello_world ring allreduce nonblocking persistent_bcast; do
echo "Testing example: $example"
mpiexec -n 4 ./target/release/examples/$example || exit 1
done
- name: Verify package
run: cargo package --allow-dirty
- name: Dry-run publish
run: cargo publish --dry-run --allow-dirty
publish:
name: Publish to crates.io
needs: [verify-and-test]
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: crates-io
url: https://crates.io/crates/ferrompi
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install MPI
run: |
sudo apt-get update
sudo apt-get install -y mpich libmpich-dev pkg-config
- name: Hotfix MPICH on Ubuntu Noble
run: |
ARCH=$(dpkg --print-architecture)
REPO=https://archive.ubuntu.com/ubuntu
LIBUCX=libucx0_1.18.1+ds-2_${ARCH}.deb
LIBMPICH=libmpich12_4.2.1-5_${ARCH}.deb
curl -sSOf ${REPO}/pool/universe/u/ucx/${LIBUCX}
curl -sSOf ${REPO}/pool/universe/m/mpich/${LIBMPICH}
TMPDIR=$(mktemp -d)
dpkg-deb -x ${LIBUCX} ${TMPDIR}
dpkg-deb -x ${LIBMPICH} ${TMPDIR}
LIBDIR=/usr/lib/$(arch)-linux-gnu
sudo cp -a ${TMPDIR}${LIBDIR}/ucx ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0 ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12 ${LIBDIR}
sudo ldconfig
rm -rf ${TMPDIR} ${LIBUCX} ${LIBMPICH}
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
create-release:
name: Create GitHub Release
needs: [publish]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Generate release notes
id: release_notes
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Try to extract changelog section
if [ -f "CHANGELOG.md" ]; then
awk "/^## \[$VERSION\]/,/^## \[/" CHANGELOG.md | sed '$d' > release_notes.txt
else
echo "Release $VERSION" > release_notes.txt
echo "" >> release_notes.txt
echo "See [CHANGELOG.md](CHANGELOG.md) for details." >> release_notes.txt
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: release_notes.txt
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}