ci: add tag-triggered GitHub release workflow with CPack zip#173
Merged
Conversation
Pushing a vX.Y.Z tag now builds the project in Release, packages everything into a .zip via CPack, and publishes a GitHub Release named after the tag with the zip attached and auto-generated notes. Pre-release tags (e.g. v0.3.3-rc1) are marked as pre-releases. Uses only first-party actions plus the gh CLI with the default GITHUB_TOKEN. Wires include(CPack) into the top-level CMakeLists (ZIP on Windows, TGZ elsewhere) so cpack can produce artifacts; the project previously never called include(CPack).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a tag-triggered GitHub Actions workflow to build and package the project with CPack, then publish a GitHub Release for the pushed tag.
Changes:
- Wire
include(CPack)into the top-level CMake configuration and set basic CPack package metadata / generator selection. - Add
.github/workflows/release.ymlto build (Release), run CPack to produce a ZIP, and publish a GitHub Release (marking*-*tags as pre-releases).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| CMakeLists.txt | Adds CPack configuration so CI can generate packaged artifacts via cpack. |
| .github/workflows/release.yml | Introduces a tag-triggered release workflow that builds, packages, and publishes GitHub Releases. |
Address PR review: (1) GitHub tag filters are glob (minimatch), not regex, so the +-quantified patterns never matched normal vX.Y.Z tags; replace with the glob 'v[0-9]*' which covers releases and pre-releases. (2) Run bootstrap-vcpkg.bat and vcpkg.exe via shell: pwsh instead of bash so the batch/exe invocations work natively on windows-latest. (3) Correct the header comment: only the numeric X.Y.Z is extracted into PROJECT_VERSION, so a pre-release suffix like -rc1 is not reflected in the built version even though the release is named after the full tag.
Address PR review: (1) Tighten the tag glob to 'v[0-9]*.[0-9]*.[0-9]*' so it requires the two dots of vX.Y.Z and no longer fires on tags like v1 or v12foo; the trailing segment still permits pre-release suffixes like -rc1. (2) Build the tests (build_tests=ON/BUILD_TESTING=ON) and run ctest before packaging, so a release artifact is never published if the suite the rest of CI runs is failing.
The on.push.tags glob can only require the vX.Y.Z shape, not digits-only segments, so tags like v1foo.2.3 or v1.2.3.4 could still trigger a release. Add a first step that regex-validates github.ref_name against strict vMAJOR.MINOR.PATCH with optional -prerelease/+build suffixes and fails fast before any build/publish when it doesn't match.
Address PR review: (1) Pin VCPKG_DEFAULT_TRIPLET/VCPKG_TARGET_TRIPLET to x64-windows (job env), pass --triplet x64-windows to vcpkg install, and add -A x64 plus -D VCPKG_TARGET_TRIPLET=x64-windows to the CMake configure so vcpkg, CMake, and the packaged artifact all agree on x64 and we never publish a 32-bit build or hit an arch mismatch. (2) Tighten the validation regex so MAJOR/MINOR/PATCH each match (0|[1-9][0-9]*), rejecting leading-zero segments like v01.2.3 to actually be strict SemVer as the step name claims.
…ease configure Address PR review: build_tests is not referenced anywhere in this project's CMake (only BUILD_TESTING is), so the cache variable was misleading; removed it. CMAKE_BUILD_TYPE has no effect with the Visual Studio multi-config generator selected by -A x64 (the config is chosen by --config/--build-config/-C Release), so removed it too and added a comment explaining the multi-config behavior.
Pre-release detection treated any hyphen in the tag as a pre-release, but SemVer build metadata may legally contain hyphens (e.g. v1.2.3+build-foo) and such tags pass the semver gate. Strip everything from the first '+' (build metadata) before testing for a '-', so only a hyphen in the pre-release position marks the GitHub release as a pre-release.
Comment on lines
+99
to
+103
| -A x64 | ||
| -D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake | ||
| -D VCPKG_TARGET_TRIPLET=x64-windows | ||
| -D BUILD_TESTING=ON | ||
| -B ${{ steps.strings.outputs.build-output-dir }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a tag-triggered release pipeline so we can publish GitHub Releases without any third-party actions.
What it does
.github/workflows/release.ymltriggers on pushing avX.Y.Ztag (andvX.Y.Z-*pre-release tags)..zipvia CPack, and publishes a GitHub Release named after the tag with the zip attached and auto-generated notes.v0.3.3-rc1) are automatically marked as pre-releases.How to cut a release
The project version already comes from this same tag (top-level CMake
git describe --tags --match "v*"), so the build version and release name always match.Notes
ghCLI with the defaultGITHUB_TOKEN— nothing needs org allow-listing.include(CPack)into the top-levelCMakeLists.txt(ZIP on Windows, TGZ elsewhere); the project previously never called it, socpackhad nothing to run.