Skip to content

Commit f86dcc3

Browse files
committed
add script to update version in test/references/*.out and update contributing.md accordingly
1 parent e6f45b2 commit f86dcc3

File tree

2 files changed

+82
-6
lines changed

2 files changed

+82
-6
lines changed

contributing.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,30 @@ When creating a new release, follow this checklist to ensure version strings are
160160
- Update line 47: `--branch vX.Y.Z` in the git clone command
161161
- Update the release notes link on line 40
162162

163-
3. **Verify version consistency**
163+
3. **Update test reference files**
164+
- Run: `./test/references/update-version.sh vX.Y.Z`
165+
- This updates version strings in all test output reference files
166+
167+
4. **Verify version consistency**
164168
- Run the version check script: `./scripts/check-version.sh vX.Y.Z`
165169
- This will verify all version strings match
166170

167-
4. **Commit the version updates**
168-
- `git add bin/combine.cpp docs/index.md`
171+
5. **Commit the version updates**
172+
- `git add bin/combine.cpp docs/index.md test/references/*.out`
169173
- `git commit -m "Update version to vX.Y.Z"`
170174

171-
5. **Create and push the tag**
175+
6. **Create and push the tag**
172176
- `git tag -a vX.Y.Z -m "Release vX.Y.Z"`
173177
- `git push origin main`
174178
- `git push origin vX.Y.Z`
175179

176-
6. **Create GitHub release**
180+
7. **Create GitHub release**
177181
- Go to [Releases](https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit/releases)
178182
- Click "Draft a new release"
179183
- Select the tag you just created
180184
- Add release notes
181185

182-
7. **Verify documentation deployment**
186+
8. **Verify documentation deployment**
183187
- Check that the [documentation](http://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/) shows the new version
184188
- The CI will automatically build and deploy docs for the new tag
185189

test/references/update-version.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
# Update version strings in test reference files
3+
# This script updates all *.out files in test/references/ with the new version
4+
5+
set -e
6+
7+
# Color codes for output
8+
RED='\033[0;31m'
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
NC='\033[0m' # No Color
12+
13+
# Check if version argument is provided
14+
if [ $# -eq 0 ]; then
15+
echo -e "${RED}Error: No version specified${NC}"
16+
echo "Usage: $0 vX.Y.Z"
17+
echo "Example: $0 v10.3.2"
18+
exit 1
19+
fi
20+
21+
NEW_VERSION=$1
22+
23+
# Validate version format
24+
if ! [[ $NEW_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
25+
echo -e "${RED}Error: Invalid version format${NC}"
26+
echo "Version must be in format vX.Y.Z (e.g., v10.3.2)"
27+
exit 1
28+
fi
29+
30+
# Get script directory
31+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
32+
33+
echo "Updating test reference files to version ${NEW_VERSION}..."
34+
echo ""
35+
36+
# Find current version in files
37+
CURRENT_VERSION=$(grep -h "<<< v" "$SCRIPT_DIR"/*.out | head -1 | sed -E 's/.*<<< (v[0-9]+\.[0-9]+\.[0-9]+) >>>.*/\1/')
38+
39+
if [ -z "$CURRENT_VERSION" ]; then
40+
echo -e "${RED}Error: Could not find current version in test files${NC}"
41+
exit 1
42+
fi
43+
44+
echo "Current version: ${CURRENT_VERSION}"
45+
echo "New version: ${NEW_VERSION}"
46+
echo ""
47+
48+
if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then
49+
echo -e "${YELLOW}Warning: Version is already ${NEW_VERSION}${NC}"
50+
echo "No changes needed."
51+
exit 0
52+
fi
53+
54+
# Update all .out files
55+
UPDATED_COUNT=0
56+
for file in "$SCRIPT_DIR"/*.out; do
57+
if [ -f "$file" ]; then
58+
if grep -q "<<< $CURRENT_VERSION >>>" "$file"; then
59+
sed -i.bak "s/<<< $CURRENT_VERSION >>>/<<< $NEW_VERSION >>>/g" "$file"
60+
rm "${file}.bak"
61+
echo -e "${GREEN}${NC} Updated: $(basename "$file")"
62+
UPDATED_COUNT=$((UPDATED_COUNT + 1))
63+
fi
64+
fi
65+
done
66+
67+
echo ""
68+
if [ $UPDATED_COUNT -eq 0 ]; then
69+
echo -e "${YELLOW}No files updated${NC}"
70+
else
71+
echo -e "${GREEN}Successfully updated $UPDATED_COUNT file(s)${NC}"
72+
fi

0 commit comments

Comments
 (0)