From 7dd4af2ef41834e219769143eb0bd0e759e8a9bb Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 23 May 2021 11:56:39 +0200 Subject: [PATCH] release --- .gitignore | 1 + doc/dev.md | 43 +++++++++++++++++++++++++++++++++++++++++++ script/release | 8 ++++---- script/release.clj | 22 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 doc/dev.md create mode 100755 script/release.clj diff --git a/.gitignore b/.gitignore index bb589b5..5597964 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules/ resources/public/js .store gh-pages/ +gh-pages/ diff --git a/doc/dev.md b/doc/dev.md new file mode 100644 index 0000000..915e8b8 --- /dev/null +++ b/doc/dev.md @@ -0,0 +1,43 @@ +# Dev + +## Release + +Static files including compiled JS are hosted on Github. This is set up like +described +[here](https://medium.com/linagora-engineering/deploying-your-js-app-to-github-pages-the-easy-way-or-not-1ef8c48424b7): + +All the commands below assume that you already have a git project initialized and that you are in its root folder. + +``` +# Create an orphan branch named gh-pages +git checkout --orphan gh-pages +# Remove all files from staging +git rm -rf . +# Create an empty commit so that you will be able to push on the branch next +git commit --allow-empty -m "Init empty branch" +# Push the branch +git push origin gh-pages +``` + +Now that the branch is created and pushed to origin, let’s configure the worktree correctly: + +``` +# Come back to master +git checkout main +# Add gh-pages to .gitignore +echo "gh-pages/" >> .gitignore +git worktree add gh-pages gh-pages +``` + +After cloning this repo to a new dir: + +``` +git fetch origin gh-pages +git worktree add gh-pages gh-pages +``` + +To deploy to Github Pages: + +``` +script/release +``` diff --git a/script/release b/script/release index b0ad19c..bcc1cff 100755 --- a/script/release +++ b/script/release @@ -2,12 +2,12 @@ set -eo pipefail -clojure -A:dev -m shadow.cljs.devtools.cli release main +clojure -M:dev -m shadow.cljs.devtools.cli release main cp resources/public/index.html gh-pages -cp resources/public/xterm.css gh-pages +sed -i 's/main.js/sci_script_tag.js/' gh-pages/index.html -mkdir -p gh-pages/ui -cp resources/public/ui/main.js gh-pages/ui/main.js +mkdir -p gh-pages/js +cp resources/public/js/main.js gh-pages/js/sci_script_tag.js cd gh-pages git add . diff --git a/script/release.clj b/script/release.clj new file mode 100755 index 0000000..284c8d4 --- /dev/null +++ b/script/release.clj @@ -0,0 +1,22 @@ +#!/usr/bin/env bb + +(require '[babashka.fs :as fs] + '[babashka.tasks :refer [shell]] + '[clojure.string :as str]) + +;; (fs/copy "resources/public/index.html" "gh-pages" +;; {:replace-existing true}) +;; (shell "clojure -M:dev -m shadow.cljs.devtools.cli release main") +;; (def index-file (fs/file "gh-pages" "index.html")) +;; (spit index-file (str/replace (slurp index-file) "main.js" "sci_script_tag.js")) +;; (fs/create-dirs (fs/file "gh-pages" "js")) +;; (fs/copy (fs/file "resources" "public" "js" "main.js") +;; (fs/file "gh-pages" "js" "sci_script_tag.js") +;; {:replace-existing true}) + +(def with-gh-pages (partial shell {:dir "gh-pages"})) +#_(with-gh-pages "git add .") +#_(with-gh-pages "git commit -m 'update build'") +(with-gh-pages "git push origin gh-pages") + +nil