Skip to content

Commit 1ed4352

Browse files
mdojulien-deramond
authored andcommitted
Streamline release prep script
1 parent 6f1783d commit 1ed4352

1 file changed

Lines changed: 24 additions & 54 deletions

File tree

build/docs-prep.sh

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ fi
1818
# Branch name to create
1919
NEW_BRANCH="gh-pages-${BRANCH_SUFFIX}"
2020

21+
# Get the current docs version from config
22+
DOCS_VERSION=$(node -p "require('js-yaml').load(require('fs').readFileSync('config.yml', 'utf8')).docs_version")
23+
2124
# Function to print colored messages
2225
print_success() {
2326
echo -e "${GREEN}$1${NC}"
@@ -92,63 +95,30 @@ print_success "Pulled latest changes from origin/gh-pages"
9295
print_info "Creating new branch ${NEW_BRANCH}"
9396
execute "git checkout -b ${NEW_BRANCH}"
9497

95-
# Step 5: Move root files
96-
print_info "Moving root files from temporary location…"
97-
ROOT_FILES=("404.html" "CNAME" "apple-touch-icon.png" "favicon.ico" "index.html" "robots.txt" "sitemap-0.xml" "sitemap-index.xml" "sw.js")
98-
for file in "${ROOT_FILES[@]}"; do
99-
if [ -f "/tmp/_site/$file" ]; then
100-
execute "mv /tmp/_site/$file ."
101-
else
102-
print_warning "File /tmp/_site/$file not found. Skipping."
103-
fi
104-
done
105-
106-
# Step 6: Move directories with cleanup
107-
print_info "Moving directories from temporary location…"
108-
DIRS=("about" "components" "docsref" "examples" "getting-started" "migration")
109-
for dir in "${DIRS[@]}"; do
110-
if [ -d "/tmp/_site/$dir" ]; then
111-
if [ -d "$dir" ]; then
112-
execute "rm -rf $dir"
113-
fi
114-
execute "mv /tmp/_site/$dir ."
115-
else
116-
print_warning "Directory /tmp/_site/$dir not found. Skipping."
117-
fi
118-
done
119-
120-
# Step 7: Handle special doc directories
121-
print_info "Handling special documentation directories…"
122-
SPECIAL_DOCS=("docs/getting-started" "docs/versions")
123-
for dir in "${SPECIAL_DOCS[@]}"; do
124-
if [ -d "/tmp/_site/$dir" ]; then
125-
if [ -d "$dir" ]; then
126-
execute "rm -rf $dir"
127-
fi
128-
# Make sure parent directory exists
129-
parent_dir=$(dirname "$dir")
130-
mkdir -p "$parent_dir"
131-
execute "mv /tmp/_site/$dir $parent_dir/"
132-
else
133-
print_warning "Directory /tmp/_site/$dir not found. Skipping."
134-
fi
135-
done
98+
# Step 5: Move all root-level files from Astro build
99+
find /tmp/_site -maxdepth 1 -type f -exec mv {} . \;
136100

137-
# Step 8: Move docs index.html
138-
if [ -f "/tmp/_site/docs/index.html" ]; then
139-
execute "mv /tmp/_site/docs/index.html docs/index.html"
140-
else
141-
print_warning "File /tmp/_site/docs/index.html not found. Skipping."
142-
fi
101+
# Step 6: Move all top-level directories except 'docs' (which needs special handling)
102+
find /tmp/_site -maxdepth 1 -type d ! -name "_site" ! -name "docs" -exec sh -c 'dir=$(basename "$1"); rm -rf "$dir"; mv "$1" .' _ {} \;
143103

144-
# Step 9: Handle docs/5.3
145-
if [ -d "/tmp/_site/docs/5.3" ]; then
146-
if [ -d "docs/5.3" ]; then
147-
execute "rm -rf docs/5.3"
104+
# Step 7: Handle docs directory specially
105+
if [ -d "/tmp/_site/docs" ]; then
106+
# Replace only the current version's docs
107+
if [ -d "docs/$DOCS_VERSION" ]; then
108+
rm -rf "docs/$DOCS_VERSION"
148109
fi
149-
execute "mv /tmp/_site/docs/5.3 docs/"
150-
else
151-
print_warning "Directory /tmp/_site/docs/5.3 not found. Skipping."
110+
mv "/tmp/_site/docs/$DOCS_VERSION" "docs/"
111+
112+
# Handle docs root files
113+
find /tmp/_site/docs -maxdepth 1 -type f -exec mv {} docs/ \;
114+
115+
# Handle special docs directories (getting-started, versions)
116+
for special_dir in getting-started versions; do
117+
if [ -d "/tmp/_site/docs/$special_dir" ]; then
118+
rm -rf "docs/$special_dir"
119+
mv "/tmp/_site/docs/$special_dir" "docs/"
120+
fi
121+
done
152122
fi
153123

154124
# Clean up remaining files in /tmp/_site if any

0 commit comments

Comments
 (0)