Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a828c38ae7 |
@@ -42,3 +42,19 @@ jobs:
|
|||||||
-H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
||||||
--upload-file dist-cdn/buuh.js.map \
|
--upload-file dist-cdn/buuh.js.map \
|
||||||
"https://project.uhhm.no/api/packages/uhhm/generic/buuh-cdn/${VERSION}/buuh.js.map"
|
"https://project.uhhm.no/api/packages/uhhm/generic/buuh-cdn/${VERSION}/buuh.js.map"
|
||||||
|
|
||||||
|
- name: publish to cdn.uhhm.no (git-pages, incremental)
|
||||||
|
run: |
|
||||||
|
VERSION="${GITHUB_REF_NAME#v}"
|
||||||
|
mkdir cdn
|
||||||
|
cp dist-cdn/buuh.js "cdn/buuh@${VERSION}.js"
|
||||||
|
cp dist-cdn/buuh.js.map "cdn/buuh@${VERSION}.js.map"
|
||||||
|
cp dist-cdn/buuh.js cdn/buuh.js
|
||||||
|
cp dist-cdn/buuh.js.map cdn/buuh.js.map
|
||||||
|
tar -czf cdn.tar.gz -C cdn .
|
||||||
|
# PATCH = incremental: earlier versions stay published forever
|
||||||
|
curl --fail -sS -X PATCH "https://cdn.uhhm.no/" \
|
||||||
|
-H "Content-Type: application/x-tar+gzip" \
|
||||||
|
-H "Forge-Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
--data-binary @cdn.tar.gz \
|
||||||
|
-w "cdn: %{http_code}\n"
|
||||||
|
|||||||
+9
-22
@@ -48,26 +48,15 @@ MIME checking). So an import map cannot point at Gitea directly.
|
|||||||
|
|
||||||
What works instead, in order of effort:
|
What works instead, in order of effort:
|
||||||
|
|
||||||
**a. The single-file bundle + any static host (recommended).**
|
**a. cdn.uhhm.no — live, and it's just a pages site (recommended).**
|
||||||
`npm run bundle` produces `dist-cdn/buuh.js` — the whole framework as
|
`https://cdn.uhhm.no/buuh@<version>.js` is real: the CDN is a git-pages
|
||||||
one minified ES module with named exports. The release workflow uploads
|
site (see uhhm/infrastructure PAGES.md) — an A record, an allowlist TXT
|
||||||
it to Gitea's generic package store as the archive of record; to make it
|
pointing at this repo, and the release workflow PATCHing each version's
|
||||||
importable, serve a copy from any host that sends
|
bundle in (PATCH is incremental, so old versions persist forever). A
|
||||||
`text/javascript` + CORS. Since you run uhhm.no, that's a few lines of
|
`_headers` file provides `Access-Control-Allow-Origin: *` everywhere,
|
||||||
Caddy:
|
year-long immutable caching on versioned files, and short caching on
|
||||||
|
`buuh.js` (the latest alias) and the index. No separate web server, no
|
||||||
```
|
Caddy site config.
|
||||||
cdn.uhhm.no {
|
|
||||||
root * /srv/cdn
|
|
||||||
file_server
|
|
||||||
header Access-Control-Allow-Origin *
|
|
||||||
header /buuh@* Cache-Control "public, max-age=31536000, immutable"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Drop each release in as `buuh@8.0.0.js` (a `curl` from the generic
|
|
||||||
package URL, or an extra `scp` step in the workflow), and every project
|
|
||||||
on earth can do:
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script type="importmap">
|
<script type="importmap">
|
||||||
@@ -78,8 +67,6 @@ on earth can do:
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
That is the zero-build story with your own domain on it.
|
|
||||||
|
|
||||||
**b. Self-hosted esm.sh.** esm.sh is open source and can be pointed at
|
**b. Self-hosted esm.sh.** esm.sh is open source and can be pointed at
|
||||||
a custom npm registry — run it against the Gitea endpoint and you get
|
a custom npm registry — run it against the Gitea endpoint and you get
|
||||||
real CDN semantics (per-package URLs, versioning, bundling) for
|
real CDN semantics (per-package URLs, versioning, bundling) for
|
||||||
|
|||||||
Reference in New Issue
Block a user