Skip to content

Commit e51bda2

Browse files
Feature/cmake alignment check (#136)
* Add CI check verifying lukka/get-cmake covers the cmake-version default Fails the PR/push if the cmake-version default (in this repo's own workflow_call.inputs) exceeds what the pinned lukka/get-cmake version's catalog supports -- exactly the situation in PR #135 (cmake-version bumped to 4.4.3 while get-cmake stayed pinned at v4.4.2, which only supports up to 4.4.2). Runs on PRs/pushes touching the three workflow files, plus on demand. A CI check (rather than a Renovate config) since this needs to validate against external data (get-cmake's own supported-version file) and should catch the mismatch regardless of whether Renovate or a human introduced it. * Move cmake alignment check script to scripts/cmake-check.sh Matches the existing convention (scripts/renovate-*.sh) instead of an inline run: block. * Move release tag/pin script to scripts/release-create.sh Same pattern as scripts/cmake-check.sh: matches the existing scripts/renovate-*.sh convention instead of an inline run: block. BUMP/REPOREF are now required env vars (fails fast with a clear error if either is unset), so the script also works standalone.
1 parent 415fa59 commit e51bda2

4 files changed

Lines changed: 100 additions & 40 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CMake alignment check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/publish-release.yml'
7+
- '.github/workflows/publish-conan-branch-package.yml'
8+
- '.github/workflows/abi-diff.yml'
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- '.github/workflows/publish-release.yml'
14+
- '.github/workflows/publish-conan-branch-package.yml'
15+
- '.github/workflows/abi-diff.yml'
16+
workflow_dispatch:
17+
18+
jobs:
19+
check:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v7
23+
24+
- name: Verify lukka/get-cmake pin covers the cmake-version default
25+
run: scripts/cmake-check.sh

.github/workflows/release.yml

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,4 @@ jobs:
2828
env:
2929
BUMP: ${{ inputs.bump }}
3030
REPOREF: dice-group/cpp-conan-release-reusable-workflow
31-
run: |
32-
set -euo pipefail
33-
34-
latest="$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n1)"
35-
if [ -z "$latest" ]; then
36-
echo "::error::No existing v*.*.* tag found to bump from."
37-
exit 1
38-
fi
39-
40-
IFS='.' read -r major minor patch <<< "${latest#v}"
41-
case "$BUMP" in
42-
major) major=$((major + 1)); minor=0; patch=0 ;;
43-
minor) minor=$((minor + 1)); patch=0 ;;
44-
patch) patch=$((patch + 1)) ;;
45-
*) echo "::error::Unknown bump type: $BUMP"; exit 1 ;;
46-
esac
47-
new="v${major}.${minor}.${patch}"
48-
49-
if git ls-remote --exit-code --tags origin "refs/tags/${new}" >/dev/null 2>&1; then
50-
echo "::error::Tag ${new} already exists."
51-
exit 1
52-
fi
53-
54-
echo "Releasing ${latest} -> ${new} (${BUMP})"
55-
56-
# Detach so the pin commit below never becomes part of main's history --
57-
# it only ever exists as the tagged commit, same as the old r/v scheme.
58-
git checkout --detach HEAD
59-
60-
sed -i -E "s#(${REPOREF}/\.github/actions/[A-Za-z0-9_-]+)@main#\1@${new}#g" .github/workflows/*.yml
61-
62-
git config user.name "github-actions[bot]"
63-
git config user.email "github-actions[bot]@users.noreply.github.com"
64-
65-
if ! git diff --quiet; then
66-
git commit -am "Pin internal actions to ${new}"
67-
fi
68-
69-
git tag "${new}"
70-
git push origin "${new}"
31+
run: scripts/release-create.sh

scripts/cmake-check.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
pins=$(grep -hoE 'lukka/get-cmake@v[0-9.]+' .github/workflows/*.yml | sed 's/.*@//' | sort -u)
5+
pin_count=$(echo "$pins" | wc -l)
6+
if [ "$pin_count" -ne 1 ]; then
7+
echo "::error::Expected exactly one lukka/get-cmake pin across .github/workflows/*.yml, found: $(echo "$pins" | tr '\n' ' ')"
8+
exit 1
9+
fi
10+
pin="$pins"
11+
12+
defaults=$(grep -A2 '^[[:space:]]*cmake-version:[[:space:]]*$' .github/workflows/*.yml | grep -oE 'default:[[:space:]]*[0-9.]+' | grep -oE '[0-9.]+' | sort -u)
13+
default_count=$(echo "$defaults" | wc -l)
14+
if [ "$default_count" -ne 1 ]; then
15+
echo "::error::Expected exactly one cmake-version default across .github/workflows/*.yml, found: $(echo "$defaults" | tr '\n' ' ')"
16+
exit 1
17+
fi
18+
default="$defaults"
19+
20+
supported=$(curl -fsSL "https://raw.githubusercontent.com/lukka/get-cmake/${pin}/.latest_cmake_version")
21+
22+
echo "lukka/get-cmake pin: ${pin} (supports CMake up to ${supported})"
23+
echo "cmake-version default in this repo: ${default}"
24+
25+
newest=$(printf '%s\n%s\n' "$supported" "$default" | sort -V | tail -n1)
26+
if [ "$newest" != "$supported" ]; then
27+
echo "::error::cmake-version default (${default}) exceeds what lukka/get-cmake@${pin} supports (${supported}). Bump the lukka/get-cmake pin before merging, or this default will break any caller that doesn't override cmake-version."
28+
exit 1
29+
fi
30+
31+
echo "OK: lukka/get-cmake@${pin} covers the cmake-version default (${default})."

scripts/release-create.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
BUMP="${BUMP:?BUMP env var (major|minor|patch) is required}"
5+
REPOREF="${REPOREF:?REPOREF env var is required}"
6+
7+
latest="$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n1)"
8+
if [ -z "$latest" ]; then
9+
echo "::error::No existing v*.*.* tag found to bump from."
10+
exit 1
11+
fi
12+
13+
IFS='.' read -r major minor patch <<< "${latest#v}"
14+
case "$BUMP" in
15+
major) major=$((major + 1)); minor=0; patch=0 ;;
16+
minor) minor=$((minor + 1)); patch=0 ;;
17+
patch) patch=$((patch + 1)) ;;
18+
*) echo "::error::Unknown bump type: $BUMP"; exit 1 ;;
19+
esac
20+
new="v${major}.${minor}.${patch}"
21+
22+
if git ls-remote --exit-code --tags origin "refs/tags/${new}" >/dev/null 2>&1; then
23+
echo "::error::Tag ${new} already exists."
24+
exit 1
25+
fi
26+
27+
echo "Releasing ${latest} -> ${new} (${BUMP})"
28+
29+
# Detach so the pin commit below never becomes part of main's history --
30+
# it only ever exists as the tagged commit, same as the old r/v scheme.
31+
git checkout --detach HEAD
32+
33+
sed -i -E "s#(${REPOREF}/\.github/actions/[A-Za-z0-9_-]+)@main#\1@${new}#g" .github/workflows/*.yml
34+
35+
git config user.name "github-actions[bot]"
36+
git config user.email "github-actions[bot]@users.noreply.github.com"
37+
38+
if ! git diff --quiet; then
39+
git commit -am "Pin internal actions to ${new}"
40+
fi
41+
42+
git tag "${new}"
43+
git push origin "${new}"

0 commit comments

Comments
 (0)