CI/CD for a C Library with Autotools and GitHub Actions
Configure, build, and test your Autotools C library on every push.
A C library using GNU Autotools follows the autoreconf, configure, make, make check flow and ships a versioned tarball via make dist. This recipe runs that flow and uploads the tarball.
What the pipeline does
- install autotools and a compiler
- bootstrap with autoreconf -i
- configure with ./configure
- build and test with make and make check
- produce a tarball with make dist
The workflow
autoreconf -i regenerates the build system from configure.ac and Makefile.am; make distcheck additionally verifies the tarball builds and tests cleanly from a clean tree.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y autoconf automake libtool build-essential
- run: autoreconf -i
- run: ./configure
- run: make -j$(nproc)
- run: make check
- run: make distcheck
- uses: actions/upload-artifact@v4
with:
name: dist-tarball
path: '*.tar.gz'Caching and speed
Cache apt packages or use ccache (cache ~/.ccache with actions/cache) to skip recompiling unchanged objects. distcheck is the slowest step because it builds twice; cheaper managed runners such as Latchkey keep these builds affordable and auto-retry transient apt-mirror failures.
Releasing
make dist produces a versioned package-X.Y.Z.tar.gz suitable for distro packaging. Attach it to a GitHub Release on tags so downstreams get a reproducible, configure-ready source tarball.
Key takeaways
- autoreconf -i regenerates the build system from your *.ac/*.am files.
- make distcheck verifies the tarball builds cleanly from scratch.
- Ship the make dist tarball as the canonical release artifact.