Skip to content

Commit 7f56903

Browse files
authored
chore: Document release schedule, add tool to check for changes (#1311)
- Updated the readme to include releasing on Wednesdays and how to do a patch version bump - Create a tool for checking which packages may need a release
1 parent cc79762 commit 7f56903

2 files changed

Lines changed: 175 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,14 @@ After completing the above, you should be able to run the release script in the
395395
396396
### Cutting a New Release
397397
398-
In order to release a given plugin, you will run the script: `tools/release.sh <pluginName>`.
399-
This must be done on a branch named `main` and will publish to the `git remote -v` named `origin` by default.
398+
Releases should be done weekly on Wednesday, unless there is an urgent need. Check which plugins have changes since the last release, by running the `tools/check_changes.sh` script. In order to release a given plugin, you will run the script: `tools/release.sh <pluginName>`.
399+
400+
This must be done on the `main` branch and will publish to the remote named `origin` by default. You can specify a different remote using the `--remote` (or `-r`) flag:
400401
401-
You can specify a different remote using the `--remote` (or `-r`) flag:
402402
```bash
403403
tools/release.sh --remote upstream <pluginName>
404404
```
405+
405406
This is useful when your `origin` points to a fork and you want to release to the upstream repository.
406407
407408
`tools/release.sh <pluginName>` will validate that your system has the necessary software installed and setup correctly, then invoke `cog bump --auto --package <pluginName>`,
@@ -414,6 +415,8 @@ See `cog.toml` to understand the full details of the release process.
414415
415416
After you have successfully run `tools/release.sh` once, you should be able to directly invoke `cog bump --auto --package <pluginName>`, or omit the `--package` to release all plugins which have updated files.
416417
418+
If you need to make a release that is just a patch version bump instead of automatically determining the version bump from commit messages, you can use `cog bump --patch --package <pluginName>`.
419+
417420
### Updating Versions in Source Code
418421
419422
As part of the release process, `cog` will, per our `cog.toml` configuration, invoke `tools/update_version.sh <packageName> <newVersion>`, which is a script that uses `sed` to update a plugin's version number in whatever source file we happen to use as the source of truth for version information in the given plugin.

tools/check_changes.sh

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/bin/bash
2+
3+
# This script checks which plugins have changes since their last tagged release.
4+
# It is useful for determining which plugins need to be released.
5+
6+
set -o errexit
7+
set -o nounset
8+
set -o pipefail
9+
10+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
11+
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
12+
13+
# Colors for output
14+
RED='\033[0;31m'
15+
GREEN='\033[0;32m'
16+
YELLOW='\033[0;33m'
17+
CYAN='\033[0;36m'
18+
NC='\033[0m' # No Color
19+
20+
# Get all plugins from the plugins directory (exclude hidden dirs like .tox)
21+
all_plugins="$(cd "$ROOT_DIR/plugins" ; find . -mindepth 1 -maxdepth 1 -type d -not -name '.*' | sed 's|./||g' | sort)"
22+
23+
verbose=false
24+
show_commits=false
25+
26+
function usage() {
27+
echo "Check which plugins have changes since their last tagged release."
28+
echo ""
29+
echo "Usage: $0 [options] [plugin...]"
30+
echo ""
31+
echo "Options:"
32+
echo " -h, --help Show this help message"
33+
echo " -v, --verbose Show detailed information about changes"
34+
echo " -c, --commits Show commit messages for changed plugins"
35+
echo ""
36+
echo "If no plugins are specified, all plugins will be checked."
37+
}
38+
39+
# Parse arguments
40+
plugins_to_check=()
41+
while (( $# > 0 )); do
42+
case "$1" in
43+
--help | -h)
44+
usage
45+
exit 0
46+
;;
47+
--verbose | -v)
48+
verbose=true
49+
;;
50+
--commits | -c)
51+
show_commits=true
52+
;;
53+
*)
54+
if grep -qE "^$1\$" <<< "$all_plugins"; then
55+
plugins_to_check+=("$1")
56+
else
57+
echo -e "${RED}Unknown plugin: $1${NC}"
58+
echo "Valid plugins are:"
59+
echo "$all_plugins"
60+
exit 1
61+
fi
62+
;;
63+
esac
64+
shift
65+
done
66+
67+
# If no plugins specified, check all
68+
if [ ${#plugins_to_check[@]} -eq 0 ]; then
69+
while IFS= read -r line; do
70+
plugins_to_check+=("$line")
71+
done <<< "$all_plugins"
72+
fi
73+
74+
cd "$ROOT_DIR"
75+
76+
changed_plugins=()
77+
unchanged_plugins=()
78+
untagged_plugins=()
79+
80+
for plugin in "${plugins_to_check[@]}"; do
81+
# Skip empty lines
82+
[ -z "$plugin" ] && continue
83+
84+
plugin_path="plugins/$plugin"
85+
86+
# Check if plugin directory exists
87+
if [ ! -d "$plugin_path" ]; then
88+
if $verbose; then
89+
echo -e "${YELLOW}Skipping $plugin: directory not found${NC}"
90+
fi
91+
continue
92+
fi
93+
94+
# Find the latest tag for this plugin
95+
latest_tag=$(git tag --list "${plugin}-v*" --sort=-v:refname | head -1)
96+
97+
if [ -z "$latest_tag" ]; then
98+
untagged_plugins+=("$plugin")
99+
if $verbose; then
100+
echo -e "${YELLOW}$plugin: No tags found${NC}"
101+
fi
102+
continue
103+
fi
104+
105+
# Count commits to the plugin directory since the last tag
106+
# Exclude version bump commits (chore(version): update ... version to *.dev0)
107+
commit_count=$(git log --oneline "${latest_tag}..HEAD" -- "$plugin_path" | grep -cvE "^[a-f0-9]+ chore\(version\): update .* version to .*\.dev0$" || true)
108+
109+
if [ "$commit_count" -gt 0 ]; then
110+
changed_plugins+=("$plugin")
111+
if $verbose; then
112+
echo -e "${GREEN}$plugin: $commit_count commit(s) since $latest_tag${NC}"
113+
fi
114+
if $show_commits; then
115+
echo -e "${CYAN} Commits since $latest_tag:${NC}"
116+
git log --oneline "${latest_tag}..HEAD" -- "$plugin_path" | grep -vE "^[a-f0-9]+ chore\(version\): update .* version to .*\.dev0$" | sed 's/^/ /'
117+
echo ""
118+
fi
119+
else
120+
unchanged_plugins+=("$plugin")
121+
if $verbose; then
122+
echo -e "${NC}$plugin: No changes since $latest_tag${NC}"
123+
fi
124+
fi
125+
done
126+
127+
# Summary
128+
echo ""
129+
echo "========================================"
130+
echo " Summary"
131+
echo "========================================"
132+
133+
if [ ${#changed_plugins[@]} -gt 0 ]; then
134+
echo -e "${GREEN}Plugins with changes (${#changed_plugins[@]}):${NC}"
135+
for plugin in "${changed_plugins[@]}"; do
136+
latest_tag=$(git tag --list "${plugin}-v*" --sort=-v:refname | head -1)
137+
commit_count=$(git log --oneline "${latest_tag}..HEAD" -- "plugins/$plugin" | grep -cvE "^[a-f0-9]+ chore\(version\): update .* version to .*\.dev0$" || true)
138+
echo -e " ${GREEN}${NC} $plugin ($commit_count commits since $latest_tag)"
139+
done
140+
echo ""
141+
fi
142+
143+
if [ ${#untagged_plugins[@]} -gt 0 ]; then
144+
echo -e "${YELLOW}Plugins without any tags (${#untagged_plugins[@]}):${NC}"
145+
for plugin in "${untagged_plugins[@]}"; do
146+
echo -e " ${YELLOW}?${NC} $plugin"
147+
done
148+
echo ""
149+
fi
150+
151+
if [ ${#unchanged_plugins[@]} -gt 0 ] && $verbose; then
152+
echo -e "Plugins with no changes (${#unchanged_plugins[@]}):"
153+
for plugin in "${unchanged_plugins[@]}"; do
154+
latest_tag=$(git tag --list "${plugin}-v*" --sort=-v:refname | head -1)
155+
echo " - $plugin (latest: $latest_tag)"
156+
done
157+
echo ""
158+
fi
159+
160+
# Suggest release commands
161+
if [ ${#changed_plugins[@]} -gt 0 ]; then
162+
echo "========================================"
163+
echo " Suggested Release Commands"
164+
echo "========================================"
165+
for plugin in "${changed_plugins[@]}"; do
166+
echo " tools/release.sh $plugin"
167+
done
168+
echo ""
169+
fi

0 commit comments

Comments
 (0)