Skip to content

Commit d8f34d8

Browse files
committed
Restructure CDN scripts
1 parent 7e83cdc commit d8f34d8

26 files changed

+38
-283
lines changed

.github/workflows/cdn-deploy.yml

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11

2-
# CDN Deployment Workflow Summary:
3-
# 1. Triggered on tag push (v*)
4-
# 2. Sets up build environment (Node.js, dependencies)
5-
# 3. Creates CDN directory structure for current version
6-
# 4. Processes core package
2+
# CDN Deployment Workflow Summary:
3+
# Workflow triggered on tag push (v*)
4+
#
5+
# 1. Creates CDN directory structure for current version
6+
# - Create bare CDN directories
7+
# - Copy over scripts to be processed
8+
# 2. Processes Core package
79
# - Creates versioned directory and redirects
810
# - Copies package files to CDN structure
9-
# 5. Processes Lit and its dependencies
10-
# - Creates versioned directories for each dependency
11-
# - Sets up proper redirects (latest -> JS entry point)
12-
# 6. Processes each @semantic-ui/* package
11+
# 3. Processes each @semantic-ui/* package
1312
# - Creates versioned directories with package contents
1413
# - Sets up redirects at multiple levels:
15-
# * /package/latest/ -> redirects to JS entry point
16-
# * /package/latest (no slash) -> redirects to JS entry point
14+
# * /package/latest/ -> redirects to latest tagged version directory listing
1715
# * /package/version/ -> directory listing (HTML)
18-
# * /package/version (no slash) -> redirects to JS entry point
19-
# * /package/ -> redirects to JS entry point
20-
# 7. Rewrites imports in all packages to use absolute CDN URLs
21-
# 8. Generates importmaps for regular and development use
22-
# 9. Creates index files and supporting documentation
23-
# 10. Deploys to gh-pages branch with clean=false to preserve previous versions
16+
# * /package/version/index.js -> exports entrypoint
17+
# * /package/index.js -> exports latest version entrypoint
18+
# * /package/ -> redirects to latest tagged version directory listing
19+
# 4. Generates importmaps for regular and development use
20+
# 5. Creates index files and supporting documentation
21+
# 6. Deploys to gh-pages branch with clean=false to preserve previous versions
2422

2523
name: Deploy CDN
2624

@@ -78,7 +76,7 @@ jobs:
7876
7977
# Create images directory and copy logo
8078
mkdir -p cdn/images
81-
cp $GITHUB_WORKSPACE/scripts/assets/images/logo.png cdn/images/
79+
cp $GITHUB_WORKSPACE/scripts/cdn/images/logo.png cdn/images/
8280
8381
# Get the main package name from package.json
8482
MAIN_PACKAGE=$(node -p "require('./package.json').name.replace('@', '').replace('/', '-')")
@@ -92,32 +90,31 @@ jobs:
9290
mkdir -p scripts/helpers
9391
9492
# generate the importmap
95-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/create-dev-importmap.js.template scripts/helpers/create-dev-importmap.js
96-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/generate-importmap.js.template scripts/helpers/generate-importmap.js
93+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/generate-importmap.js.template scripts/helpers/generate-importmap.js
9794
9895
# create importmap-loaders
99-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/importmap-loader.js.template scripts/helpers/importmap-loader.js
100-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/importmap-dev-loader.js.template scripts/helpers/importmap-dev-loader.js
101-
102-
# create importmap loader js for dev
103-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/create-dev-loader.js.template scripts/helpers/create-dev-loader.js
96+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/importmap-loader.js.template scripts/helpers/importmap-loader.js
10497
10598
# redirects /latest to tagged folder
106-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/latest-redirect.html.template scripts/helpers/latest-redirect.html.template
99+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/latest-redirect.html.template scripts/helpers/latest-redirect.html.template
107100
108101
# find entrypoint for package from package.json
109-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/resolve-entry.js.template scripts/helpers/resolve-entry.js
102+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/resolve-entry.js.template scripts/helpers/resolve-entry.js
110103
111104
# gets dep version from node_modules
112-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/get-dependency-version.js.template scripts/helpers/get-dependency-version.js
105+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/get-dependency-version.js.template scripts/helpers/get-dependency-version.js
106+
107+
# currently using bundled deps. will consider revisiting cdnized bare module imports
113108
# get lit deps
114-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/get-lit-dependencies.js.template scripts/helpers/get-lit-dependencies.js
109+
#cp $GITHUB_WORKSPACE/scripts/cdn/templates/get-lit-dependencies.js.template scripts/helpers/get-lit-dependencies.js
115110
# get lit version
116-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/get-lit-version.js.template scripts/helpers/get-lit-version.js
111+
#cp $GITHUB_WORKSPACE/scripts/cdn/templates/get-lit-version.js.template scripts/helpers/get-lit-version.js
112+
113+
117114
# gets package files to copy
118-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/get-package-files.js.template scripts/helpers/get-package-files.js
115+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/get-package-files.js.template scripts/helpers/get-package-files.js
119116
## get package.json
120-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/resolve-package-entry.js.template scripts/helpers/resolve-package-entry.js
117+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/resolve-package-entry.js.template scripts/helpers/resolve-package-entry.js
121118
122119
###----------------------------------------###
123120
### Create CDN Copy of Core Package ###
@@ -157,7 +154,7 @@ jobs:
157154
cp package.json cdn/@semantic-ui/core/$CORE_VERSION/package.json
158155
159156
# Create index.js and index.html files for the core package using templates
160-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/core-index.js.template cdn/@semantic-ui/core/$CORE_VERSION/index.js
157+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/core-index.js.template cdn/@semantic-ui/core/$CORE_VERSION/index.js
161158
162159
# Use perl instead of sed for better handling of special characters
163160
perl -i -pe "s|CORE_ENTRY|$core_entry|g" cdn/@semantic-ui/core/$CORE_VERSION/index.js
@@ -167,7 +164,7 @@ jobs:
167164
gsub(/CORE_VERSION/, version);
168165
gsub(/CORE_ENTRY/, entry);
169166
print
170-
}' $GITHUB_WORKSPACE/scripts/assets/templates/cdn/core-index.html.template > cdn/@semantic-ui/core/$CORE_VERSION/index.html
167+
}' $GITHUB_WORKSPACE/scripts/cdn/templates/core-index.html.template > cdn/@semantic-ui/core/$CORE_VERSION/index.html
171168
172169
# Create latest redirect for core with proper escaping
173170
awk -v version="$CORE_VERSION" -v pkgname="@semantic-ui/core" '{
@@ -203,11 +200,11 @@ jobs:
203200
echo "$package_name entry resolved to: $pkg_entry"
204201
205202
# Create index.js and index.html files using templates
206-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/package-index.js.template "../cdn/@semantic-ui/$package_name/$pkg_version/index.js"
203+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/package-index.js.template "../cdn/@semantic-ui/$package_name/$pkg_version/index.js"
207204
# Use perl instead of sed for better handling of special characters
208205
perl -i -pe "s|PACKAGE_ENTRY|$pkg_entry|g" "../cdn/@semantic-ui/$package_name/$pkg_version/index.js"
209206
210-
cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/package-index.html.template "../cdn/@semantic-ui/$package_name/$pkg_version/index.html"
207+
cp $GITHUB_WORKSPACE/scripts/cdn/templates/package-index.html.template "../cdn/@semantic-ui/$package_name/$pkg_version/index.html"
211208
perl -i -pe "s|PACKAGE_NAME|$package_name|g" "../cdn/@semantic-ui/$package_name/$pkg_version/index.html"
212209
perl -i -pe "s|PACKAGE_VERSION|$pkg_version|g" "../cdn/@semantic-ui/$package_name/$pkg_version/index.html"
213210
perl -i -pe "s|PACKAGE_ENTRY|$pkg_entry|g" "../cdn/@semantic-ui/$package_name/$pkg_version/index.html"
@@ -268,7 +265,7 @@ jobs:
268265
awk -v version="$CORE_VERSION" '{
269266
gsub(/\${VERSION}/, version);
270267
print
271-
}' $GITHUB_WORKSPACE/scripts/assets/templates/cdn/package-root-js.template > cdn/@semantic-ui/core/index.js
268+
}' $GITHUB_WORKSPACE/scripts/cdn/templates/package-root-js.template > cdn/@semantic-ui/core/index.js
272269
273270
# Create redirects for each package
274271
cd packages
@@ -284,13 +281,13 @@ jobs:
284281
gsub(/\${VERSION}/, version);
285282
gsub(/\${PACKAGE_NAME}/, pkgname);
286283
print
287-
}' $GITHUB_WORKSPACE/scripts/assets/templates/cdn/latest-redirect.html.template > "../cdn/@semantic-ui/$package_name/index.html"
284+
}' $GITHUB_WORKSPACE/scripts/cdn/templates/latest-redirect.html.template > "../cdn/@semantic-ui/$package_name/index.html"
288285
289286
# Create JavaScript redirect file for importmap compatibility
290287
awk -v version="$pkg_version" '{
291288
gsub(/\${VERSION}/, version);
292289
print
293-
}' $GITHUB_WORKSPACE/scripts/assets/templates/cdn/package-root-js.template > "../cdn/@semantic-ui/$package_name/index.js"
290+
}' $GITHUB_WORKSPACE/scripts/cdn/templates/package-root-js.template > "../cdn/@semantic-ui/$package_name/index.js"
294291
done
295292
cd ..
296293
@@ -302,12 +299,12 @@ jobs:
302299
echo "cdn.semantic-ui.com" > cdn/CNAME
303300
304301
# Create README.md for the CDN using the gh-pages README
305-
cp $GITHUB_WORKSPACE/scripts/assets/gh-pages/README.md cdn/README.md
302+
cp $GITHUB_WORKSPACE/scripts/cdn/gh-pages/README.md cdn/README.md
306303
# Update the version references in the README
307304
sed -i "s/\${VERSION}/$VERSION/g" cdn/README.md
308305
309306
# Create index file for the CDN root
310-
cp $GITHUB_WORKSPACE/scripts/assets/gh-pages/index.html cdn/index.html
307+
cp $GITHUB_WORKSPACE/scripts/cdn/gh-pages/index.html cdn/index.html
311308
# Update version references
312309
sed -i "s/\${VERSION}/$VERSION/g" cdn/index.html
313310
# Fix the CDN link reference

0 commit comments

Comments
 (0)