All jobs

Add a GitHub Release Workflow With CPack Packages to a CMake Project

Yes. An agent adds a tag-triggered workflow that builds, runs the tests, packages the project with CPack and attaches the .deb, .rpm and tarball to a GitHub release.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the CMake project and the packaging it already declares, because most of the work is usually done and never wired to a release. In a library like p-ranav/argparse, CMakeLists.txt declares project(argparse VERSION 3.2.0 ...) as a header-only INTERFACE target, with ARGPARSE_INSTALL and ARGPARSE_BUILD_TESTS on when it is the top-level project. The install block exports argparseConfig.cmake and a version file with SameMajorVersion compatibility, installs include/argparse/argparse.hpp, and configures packaging/pkgconfig.pc.in into argparse.pc. Below that, forty lines of CPACK_* variables name the Debian package libargparse-dev depending on libc6-dev, the RPM libargparse-devel, xz compression and the license and readme files, and the file ends with include(CPack). There is no CPACK_GENERATOR, so a bare cpack makes only the CMake defaults. .github/workflows/ci.yml runs on pull requests over a seven-toolchain matrix, configures inside test/ with cmake -S . -B build, builds, and runs ./tests (the doctest binary from test/CMakeLists.txt, compiled with -Werror). There is no workflow for tags. conanfile.py still says version = "3.1", which the agent notes rather than fixes.

It adds .github/workflows/release.yml, triggered by push on tags that start with v and by workflow_dispatch. The one job runs on ubuntu-latest, installs rpm so the RPM generator has rpmbuild, configures the top-level project with -DARGPARSE_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release, builds, and runs the test binary, so a tag on a broken commit never becomes a release. A step then compares the tag to the version CMake reports: it reads project(... VERSION ...) from the configure output's cache (CMAKE_PROJECT_VERSION in CMakeCache.txt) and fails if v3.2.0 was tagged on a tree that says 3.2.1, which is the mistake a release workflow exists to catch. Packaging is cpack -G "TGZ;DEB;RPM" from the build directory, followed by sha256sum over the artifacts into a SHA256SUMS file. The release step uses gh release create with the tag, the three packages and the checksums, --generate-notes, and --draft so a person reads the notes before anyone sees them; the job has permissions: contents: write and nothing more.

Before it writes the workflow, the agent runs the same steps in its sandbox: configure, build, ./test/tests, then cpack with the three generators. It opens the results rather than trusting the exit code: dpkg-deb --info on the .deb shows the package name libargparse-dev, the libc6-dev dependency and the maintainer from CPACK_PACKAGE_MAINTAINER; dpkg-deb --contents lists usr/include/argparse/argparse.hpp, usr/lib/cmake/argparse/argparseConfig.cmake with its version file, and usr/lib/pkgconfig/argparse.pc; rpm -qpl does the same for the RPM, and tar tzf for the tarball. That is how it learns the generated .deb is named by the CPack defaults and sets CPACK_PACKAGE_FILE_NAME to include the version and architecture only if the project does not already, without touching the rest of the CPack block.

The workflow is validated with actionlint, and the agent writes a short Releasing section in README.md: tag the commit with the version from CMakeLists.txt, push the tag, and publish the draft. It does not change ci.yml, the Conan or Bazel files, or the test matrix, and it does not change the version.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add a GitHub release workflow to this CMake project. Read CMakeLists.txt, everything under packaging and test, the existing workflows and the README first, and note the CPack variables that are already set. In the sandbox, configure the top-level project with tests on and Release build type, build, run the test binary, then run cpack with the TGZ, DEB and RPM generators and inspect the packages with dpkg-deb, rpm and tar to confirm the header, the CMake config files and the pkg-config file are inside and the package names and dependencies match the CPack variables. Then write .github/workflows/release.yml triggered by tags starting with v and by workflow_dispatch: build and test, fail if the tag does not match the version CMake reports, run cpack with the three generators, write SHA256SUMS, and create a draft GitHub release with generated notes and the files attached, with contents write permission only. Validate the workflow with actionlint, add a short Releasing section to the README, change nothing else, and open a pull request that shows the package contents you inspected.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that adds .github/workflows/release.yml and a Releasing section to README.md, and changes CMakeLists.txt only if a package file name had to be set. The description lists the three artifacts the workflow produces, with the dpkg-deb --info and --contents output from the sandbox showing libargparse-dev, its libc6-dev dependency, and the header, CMake config and pkg-config paths inside.

The run's record keeps the configure and build output, the test binary's result, the cpack log for each generator and the actionlint run, so a reviewer sees the packages were built from this tree and not described from the CMake file. The description also says that conanfile.py carries an older version string, as a note for a separate change.

Before merging, a reviewer pushes a test tag such as v3.2.0-rc1 on a branch, or runs the workflow by hand with workflow_dispatch, and sees a draft release with four files attached and notes generated from the merged pull requests. They delete the draft and the tag, and the next real tag publishes the same way.

Run it on every C++ project

A team that maintains several CMake libraries hands this off from the terminal once per repository: one POST /o/{org}/sessions with this body and the repository in resources. Each run reads that project's own CPACK_* variables and test layout, so a project with CPACK_GENERATOR already set keeps it and one that tests through ctest runs ctest --output-on-failure instead of a binary. A request_id that is a UUID v5 of the repository name makes a retried request return the run it already started.

The key's webhook_url reports each run the key starts, with the pull request URL in result, so a script that sends one request per repository collects the pull requests in one place.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A release workflow is trusted only once someone has watched it produce real packages. The agent produces them in its own sandbox first, opens each with dpkg-deb, rpm and tar, and writes the workflow from what it saw, with every command and listing kept in the run's record for the reviewer.

The version guard, the draft release and the minimal permission are the three details that are easy to leave out when the workflow is written from memory, and they are what keep a mistyped tag or a broken commit from becoming a public release.

Frequently asked questions

Why a draft release instead of publishing on tag?

So a person reads the generated notes and the attached files before users see them. Publishing is one click in the GitHub UI, and the workflow does the slow part. A team that wants fully automatic releases removes the --draft flag; the pull request shows the line.

What if the tag does not match the project version?

The job fails before packaging, with both values in the log. The fix is to retag after bumping project(... VERSION ...), which is the only place the version is meant to live; the Conan file's separate version string is noted in the pull request as a second copy worth removing.

Does this add Windows or macOS packages?

No. The CPack block in this project configures Debian and RPM metadata and nothing for NSIS or productbuild, so the workflow packages what the project already describes. A header-only library installs the same files on every platform, and the tarball covers the rest.

Will the existing CI change?

No. ci.yml keeps running the seven-toolchain matrix on pull requests. The release workflow builds and tests again on the tagged commit on one Linux runner, because that is the tree being packaged.

How do I know the packages install correctly?

The pull request shows the package listings from the sandbox, and a reviewer can dpkg -i the .deb from the draft release on a Debian or Ubuntu machine and configure a project with find_package(argparse CONFIG) against it.

More CMake jobs

The same job on other stacks

Keep reading