Skip to content

Commit

Permalink
build: add build task for deploy repos to use
Browse files Browse the repository at this point in the history
The build task collects runtime files into the ./dist dir. This is
useful for separate deployment repos to deploy anonystat using the
deployctl action.
  • Loading branch information
h4l committed May 19, 2024
1 parent f83a41d commit 37c2083
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.lcov
/cov_profile
/html_cov
/dist
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"clean-cov": "rm -rf html_cov cov.lcov cov_profile",
"cov-html": "deno coverage --lcov --output=cov.lcov cov_profile/ && genhtml -o html_cov cov.lcov",
"serve-cov": "deno run --allow-net --allow-read --allow-sys https://deno.land/std/http/file_server.ts html_cov",
"cov": "deno task clean-cov && deno task test-cov && deno task cov-html && deno task serve-cov"
"cov": "deno task clean-cov && deno task test-cov && deno task cov-html && deno task serve-cov",
"build": "scripts/build.sh"
},
"deploy": {
"exclude": [
Expand Down
18 changes: 18 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

# Collect anonystat files needed at runtime into $OUT_DIR (./dist by default).
# This must be run from the repo root.

OUT_DIR=${OUT_DIR:-dist}
mkdir -p "${OUT_DIR:?}"

# Include the deno.json/deno.lock with the hope that Deno Deploy uses the
# lockfile when resolving deps. I can't find any documentation that indicates
# whether it does or not though.
git ls-files . \
| grep -P '^(.*\.ts|deno.json|deno.lock)$' \
| grep -Pv '_test(ing)?\b|scripts/' \
| xargs -I{} install -D --mode a=r,u+w {} "${OUT_DIR:?}/{}"

echo "anonystat runtime files collected in ${OUT_DIR:?}" >&2

0 comments on commit 37c2083

Please sign in to comment.