Skip to content

Commit 49e7b51

Browse files
Merge branch 'main' into aws-snapshot
2 parents 641995d + f04d7d2 commit 49e7b51

File tree

75 files changed

+1126
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1126
-195
lines changed

.github/scripts/tag_release.sh

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
#!/bin/bash
2+
3+
# Tag Release Script
4+
# Automatically detects modules that need tagging and creates release tags
5+
# Usage: ./tag_release.sh
6+
# Operates on the current checked-out commit
7+
8+
set -euo pipefail
9+
10+
MODULES_TO_TAG=()
11+
12+
usage() {
13+
echo "Usage: $0"
14+
echo ""
15+
echo "This script will:"
16+
echo " 1. Scan all modules in the registry"
17+
echo " 2. Check which modules need new release tags"
18+
echo " 3. Extract version information from README files"
19+
echo " 4. Generate a report for confirmation"
20+
echo " 5. Create and push release tags after confirmation"
21+
echo ""
22+
echo "The script operates on the current checked-out commit."
23+
echo "Make sure you have checked out the commit you want to tag before running."
24+
exit 1
25+
}
26+
27+
validate_version() {
28+
local version="$1"
29+
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
30+
echo "❌ Invalid version format: '$version'. Expected X.Y.Z format." >&2
31+
return 1
32+
fi
33+
return 0
34+
}
35+
36+
extract_version_from_readme() {
37+
local readme_path="$1"
38+
local namespace="$2"
39+
local module_name="$3"
40+
41+
[ ! -f "$readme_path" ] && return 1
42+
43+
local version_line
44+
version_line=$(grep -E "source\s*=\s*\"registry\.coder\.com/${namespace}/${module_name}" "$readme_path" | head -1 || echo "")
45+
46+
if [ -n "$version_line" ]; then
47+
local version
48+
version=$(echo "$version_line" | sed -n 's/.*version\s*=\s*"\([^"]*\)".*/\1/p')
49+
if [ -n "$version" ]; then
50+
echo "$version"
51+
return 0
52+
fi
53+
fi
54+
55+
local fallback_version
56+
fallback_version=$(grep -E 'version\s*=\s*"[0-9]+\.[0-9]+\.[0-9]+"' "$readme_path" | head -1 | sed 's/.*version\s*=\s*"\([^"]*\)".*/\1/' || echo "")
57+
58+
if [ -n "$fallback_version" ]; then
59+
echo "$fallback_version"
60+
return 0
61+
fi
62+
63+
return 1
64+
}
65+
66+
check_module_needs_tagging() {
67+
local namespace="$1"
68+
local module_name="$2"
69+
local readme_version="$3"
70+
71+
local tag_name="release/${namespace}/${module_name}/v${readme_version}"
72+
73+
if git rev-parse --verify "$tag_name" > /dev/null 2>&1; then
74+
return 1
75+
else
76+
return 0
77+
fi
78+
}
79+
80+
detect_modules_needing_tags() {
81+
MODULES_TO_TAG=()
82+
83+
echo "🔍 Scanning all modules for missing release tags..."
84+
echo ""
85+
86+
local all_modules
87+
all_modules=$(find registry -mindepth 3 -maxdepth 3 -type d -path "*/modules/*" | sort -u || echo "")
88+
89+
[ -z "$all_modules" ] && {
90+
echo "❌ No modules found to check"
91+
return 1
92+
}
93+
94+
local total_checked=0
95+
local needs_tagging=0
96+
97+
while IFS= read -r module_path; do
98+
if [ -z "$module_path" ]; then continue; fi
99+
100+
local namespace
101+
namespace=$(echo "$module_path" | cut -d'/' -f2)
102+
local module_name
103+
module_name=$(echo "$module_path" | cut -d'/' -f4)
104+
105+
total_checked=$((total_checked + 1))
106+
107+
local readme_path="$module_path/README.md"
108+
local readme_version
109+
110+
if ! readme_version=$(extract_version_from_readme "$readme_path" "$namespace" "$module_name"); then
111+
echo "⚠️ $namespace/$module_name: No version found in README, skipping"
112+
continue
113+
fi
114+
115+
if ! validate_version "$readme_version"; then
116+
echo "⚠️ $namespace/$module_name: Invalid version format '$readme_version', skipping"
117+
continue
118+
fi
119+
120+
if check_module_needs_tagging "$namespace" "$module_name" "$readme_version"; then
121+
echo "📦 $namespace/$module_name: v$readme_version (needs tag)"
122+
MODULES_TO_TAG+=("$module_path:$namespace:$module_name:$readme_version")
123+
needs_tagging=$((needs_tagging + 1))
124+
else
125+
echo "$namespace/$module_name: v$readme_version (already tagged)"
126+
fi
127+
128+
done <<< "$all_modules"
129+
130+
echo ""
131+
echo "📊 Summary: $needs_tagging of $total_checked modules need tagging"
132+
echo ""
133+
134+
[ $needs_tagging -eq 0 ] && {
135+
echo "🎉 All modules are up to date! No tags needed."
136+
return 0
137+
}
138+
139+
echo "## Tags to be created:"
140+
for module_info in "${MODULES_TO_TAG[@]}"; do
141+
IFS=':' read -r module_path namespace module_name version <<< "$module_info"
142+
echo "- \`release/$namespace/$module_name/v$version\`"
143+
done
144+
echo ""
145+
146+
return 0
147+
}
148+
149+
create_and_push_tags() {
150+
[ ${#MODULES_TO_TAG[@]} -eq 0 ] && {
151+
echo "❌ No modules to tag found"
152+
return 1
153+
}
154+
155+
local current_commit
156+
current_commit=$(git rev-parse HEAD)
157+
158+
echo "🏷️ Creating release tags for commit: $current_commit"
159+
echo ""
160+
161+
local created_tags=0
162+
local failed_tags=0
163+
164+
for module_info in "${MODULES_TO_TAG[@]}"; do
165+
IFS=':' read -r module_path namespace module_name version <<< "$module_info"
166+
167+
local tag_name="release/$namespace/$module_name/v$version"
168+
local tag_message="Release $namespace/$module_name v$version"
169+
170+
echo "Creating tag: $tag_name"
171+
172+
if git tag -a "$tag_name" -m "$tag_message" "$current_commit"; then
173+
echo "✅ Created: $tag_name"
174+
created_tags=$((created_tags + 1))
175+
else
176+
echo "❌ Failed to create: $tag_name"
177+
failed_tags=$((failed_tags + 1))
178+
fi
179+
done
180+
181+
echo ""
182+
echo "📊 Tag creation summary:"
183+
echo " Created: $created_tags"
184+
echo " Failed: $failed_tags"
185+
echo ""
186+
187+
[ $created_tags -eq 0 ] && {
188+
echo "❌ No tags were created successfully"
189+
return 1
190+
}
191+
192+
echo "🚀 Pushing tags to origin..."
193+
194+
local tags_to_push=()
195+
for module_info in "${MODULES_TO_TAG[@]}"; do
196+
IFS=':' read -r module_path namespace module_name version <<< "$module_info"
197+
local tag_name="release/$namespace/$module_name/v$version"
198+
199+
if git rev-parse --verify "$tag_name" > /dev/null 2>&1; then
200+
tags_to_push+=("$tag_name")
201+
fi
202+
done
203+
204+
local pushed_tags=0
205+
local failed_pushes=0
206+
207+
if [ ${#tags_to_push[@]} -eq 0 ]; then
208+
echo "❌ No valid tags found to push"
209+
else
210+
if git push --atomic origin "${tags_to_push[@]}"; then
211+
echo "✅ Successfully pushed all ${#tags_to_push[@]} tags"
212+
pushed_tags=${#tags_to_push[@]}
213+
else
214+
echo "❌ Failed to push tags"
215+
failed_pushes=${#tags_to_push[@]}
216+
fi
217+
fi
218+
219+
echo ""
220+
echo "📊 Push summary:"
221+
echo " Pushed: $pushed_tags"
222+
echo " Failed: $failed_pushes"
223+
echo ""
224+
225+
if [ $pushed_tags -gt 0 ]; then
226+
echo "🎉 Successfully created and pushed $pushed_tags release tags!"
227+
echo ""
228+
echo "📝 Next steps:"
229+
echo " - Tags will be automatically published to registry.coder.com"
230+
echo " - Monitor the registry website for updates"
231+
echo " - Check GitHub releases for any issues"
232+
fi
233+
234+
return 0
235+
}
236+
237+
main() {
238+
[ $# -gt 0 ] && usage
239+
240+
echo "🚀 Coder Registry Tag Release Script"
241+
echo "Operating on commit: $(git rev-parse HEAD)"
242+
echo ""
243+
244+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
245+
echo "❌ Not in a git repository"
246+
exit 1
247+
fi
248+
249+
detect_modules_needing_tags || exit 1
250+
251+
[ ${#MODULES_TO_TAG[@]} -eq 0 ] && {
252+
echo "✨ No modules need tagging. All done!"
253+
exit 0
254+
}
255+
256+
echo ""
257+
echo "❓ Do you want to proceed with creating and pushing these release tags?"
258+
echo " This will create git tags and push them to the remote repository."
259+
echo ""
260+
read -p "Continue? [y/N]: " -r response
261+
262+
case "$response" in
263+
[yY] | [yY][eE][sS])
264+
echo ""
265+
create_and_push_tags
266+
;;
267+
*)
268+
echo ""
269+
echo "🚫 Operation cancelled by user"
270+
exit 0
271+
;;
272+
esac
273+
}
274+
275+
main "$@"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,6 @@ dist
145145

146146
# Generated credentials from google-github-actions/auth
147147
gha-creds-*.json
148+
149+
# IDEs
150+
.idea

.icons/tmux.svg

Lines changed: 1 addition & 0 deletions
Loading

MAINTAINER.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ Changes are automatically published to [registry.coder.com](https://registry.cod
7272
display_name: "Module Name"
7373
description: "What it does"
7474
icon: "../../../../.icons/tool.svg"
75-
maintainer_github: "username"
76-
partner_github: "partner-name" # Optional - For official partner modules
7775
verified: false # Optional - Set by maintainers only
7876
tags: ["tag1", "tag2"]
7977
```

examples/modules/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
display_name: MODULE_NAME
33
description: Describe what this module does
44
icon: ../../../../.icons/<A_RELEVANT_ICON>.svg
5-
maintainer_github: GITHUB_USERNAME
65
verified: false
76
tags: [helper]
87
---

registry/anomaly/.images/avatar.jpeg

8.85 KB
Loading

registry/anomaly/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
display_name: "Jay Kumar"
3+
bio: "I'm a Software Engineer :)"
4+
avatar_url: "./.images/avatar.png"
5+
github: "35C4n0r"
6+
linkedin: "https://www.linkedin.com/in/jaykum4r"
7+
support_email: "[email protected]"
8+
status: "community"
9+
---
10+
11+
# Your Name
12+
13+
I'm a Software Engineer :)

0 commit comments

Comments
 (0)