CI: re-jig publish

This commit is contained in:
TEC 2022-12-09 20:02:49 +08:00
parent babcd39795
commit 9926f993c8
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
11 changed files with 234 additions and 119 deletions

View File

@ -3,8 +3,8 @@ on:
pull_request:
push:
branches: master
schedule:
- cron: "0 */2 * * *" # every 2h
# schedule:
# - cron: "0 */2 * * *" # every 2h
jobs:
deploy:
@ -22,14 +22,14 @@ jobs:
- name: Get Doom's version
id: doom-version
run: runner 'cd ~/.config/emacs && echo "::set-output name=hash::$(git log -1 | head -1 | awk '"'"'{print substr($2,1,7)}'"'"')"'
run: runner 'cd ~/.config/emacs && echo "doom_hash=$(git log -1 | head -1 | awk '"'"'{print substr($2,1,8)}'"'"')"' >> $GITHUB_ENV
- name: Cache Doom's Install
id: doomcache
uses: actions/cache@v2
with:
path: /home/runner/.config/emacs
key: ${{ runner.os }}-doom@${{ steps.doom-version.outputs.hash }}
key: ${{ runner.os }}-doom@${{ env.doom_hash }}
- name: Checkout config
if: github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true'
@ -47,22 +47,26 @@ jobs:
if: github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true'
run: runner '~/.config/emacs/bin/doom sync'
- name: Rebuild changed packages
if: github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true'
run: runner '~/.config/emacs/bin/doom build -r'
- name: Ensure emoji vector graphics exist
if: github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true'
run: runner "emacs --batch --eval \"(progn (load \\\"~/.config/emacs/lisp/doom.el\\\") (require 'doom-cli) (doom-initialize-packages) (load \\\"~/.config/doom/subconf/ox-latex-emoji.el\\\") (unless (file-exists-p (expand-file-name \\\"twemoji\\\" org-latex-emoji-base-dir)) (org-latex-emoji-install \\\"twemoji\\\" t)))\""
# - name: Export config
# if: github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true'
# run: runner 'cd ~/.config/doom/misc/config-publishing && ./publish.sh'
- name: Export config
if: github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true'
run: runner 'cd ~/.config/doom/misc/config-publishing && ./publish.sh'
- name: Deploy
if: github.event_name != 'pull_request' && ( github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true')
if: github.event_name != 'pull_request' && (github.event_name != 'schedule' || steps.doomcache.outputs.cache-hit != 'true') && success()
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: /home/runner/.config/doom/publish
force_orphan: true
# - name: Debug over SSH (tmate)
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3.1
- name: Debug over SSH (tmate)
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3.1

View File

@ -67,8 +67,10 @@
(message "\033[0;31m %s\033[0m"
'unmodified
(with-temp-buffer
(insert-file-contents-literally (expand-file-name ,(format "%s-log.txt" (file-name-base file))
(file-name-directory load-file-name)))
(let ((log-file ,(expand-file-name (format "%s-log.txt" (file-name-base file))
(file-name-directory load-file-name))))
(when (file-exists-p log-file)
(insert-file-contents-literally log-file)))
(buffer-substring-no-properties (point-min) (point-max))))
(message "[1;31] Config publishing aborted%s" (apm-space-fill-line 23))
(kill-emacs 1)))))))

View File

@ -0,0 +1,54 @@
;;; misc/config-publishing/doom-one-light-engraved-theme.el -*- lexical-binding: t; -*-
(require 'engrave-faces)
(add-to-list 'engrave-faces-themes
'(doom-one-light ; Comments are slightly darkened for readability
(default :short "default" :slug "D" :foreground "#383a42" :background "#fafafa" :slant normal :weight normal)
(variable-pitch :short "var-pitch" :slug "vp" :height 176)
(shadow :short "shadow" :slug "h" :foreground "#84888b")
(success :short "success" :slug "sc" :foreground "#50a14f")
(warning :short "warning" :slug "w" :foreground "#986801")
(error :short "error" :slug "e" :foreground "#e45649")
(link :short "link" :slug "l" :foreground "#4078f2" :weight bold)
(link-visited :short "link" :slug "lv" :foreground "#8b008b" :weight bold)
(highlight :short "link" :slug "hi" :foreground "#f0f0f0" :background "#4078f2")
(font-lock-comment-face :short "fl-comment" :slug "c" :foreground "#84888b")
(font-lock-comment-delimiter-face :short "fl-comment-delim" :slug "cd" :foreground "#84888b")
(font-lock-string-face :short "fl-string" :slug "s" :foreground "#50a14f")
(font-lock-doc-face :short "fl-doc" :slug "d" :foreground "#727578" :slant italic)
(font-lock-doc-markup-face :short "fl-doc-markup" :slug "m" :foreground "#b751b6")
(font-lock-keyword-face :short "fl-keyword" :slug "k" :foreground "#e45649")
(font-lock-builtin-face :short "fl-builtin" :slug "b" :foreground "#a626a4")
(font-lock-function-name-face :short "fl-function" :slug "f" :foreground "#a626a4")
(font-lock-variable-name-face :short "fl-variable" :slug "v" :foreground "#6a1868")
(font-lock-type-face :short "fl-type" :slug "t" :foreground "#986801")
(font-lock-constant-face :short "fl-constant" :slug "o" :foreground "#b751b6")
(font-lock-warning-face :short "fl-warning" :slug "wr" :foreground "#986801")
(font-lock-negation-char-face :short "fl-neg-char" :slug "nc" :foreground "#4078f2" :weight bold)
(font-lock-preprocessor-face :short "fl-preprocessor" :slug "pp" :foreground "#4078f2" :weight bold)
(font-lock-regexp-grouping-construct :short "fl-regexp" :slug "rc" :foreground "#4078f2" :weight bold)
(font-lock-regexp-grouping-backslash :short "fl-regexp-backslash" :slug "rb" :foreground "#4078f2" :weight bold)
(org-block :short "org-block" :slug "ob" :background "#e7e7e7")
(org-block-begin-line :short "org-block-begin" :slug "obb" :background "#e7e7e7" :slant italic)
(org-block-end-line :short "org-block-end" :slug "obe" :background "#e7e7e7" :slant italic)
(outline-1 :short "outline-1" :slug "Oa" :foreground "#e45649" :weight extra-bold :height 1.25)
(outline-2 :short "outline-2" :slug "Ob" :foreground "#da8548" :weight bold :height 1.15)
(outline-3 :short "outline-3" :slug "Oc" :foreground "#b751b6" :weight bold :height 1.12)
(outline-4 :short "outline-4" :slug "Od" :foreground "#6f99f5" :weight semi-bold :height 1.09)
(outline-5 :short "outline-5" :slug "Oe" :foreground "#bc5cba" :weight semi-bold :height 1.06)
(outline-6 :short "outline-6" :slug "Of" :foreground "#9fbbf8" :weight semi-bold :height 1.03)
(outline-7 :short "outline-7" :slug "Og" :foreground "#d292d1" :weight bold)
(outline-8 :short "outline-8" :slug "Oh" :foreground "#d8e4fc" :weight semi-bold)
(highlight-numbers-number :short "hl-number" :slug "hn" :foreground "#da8548" :weight bold)
(highlight-quoted-quote :short "hl-qquote" :slug "hq" :foreground "#4078f2")
(highlight-quoted-symbol :short "hl-qsymbol" :slug "hs" :foreground "#986801")
(rainbow-delimiters-depth-1-face :short "rd-1" :slug "rda" :foreground "#4078f2")
(rainbow-delimiters-depth-2-face :short "rd-2" :slug "rdb" :foreground "#a626a4")
(rainbow-delimiters-depth-3-face :short "rd-3" :slug "rdc" :foreground "#50a14f")
(rainbow-delimiters-depth-4-face :short "rd-4" :slug "rdd" :foreground "#b751b6")
(rainbow-delimiters-depth-5-face :short "rd-5" :slug "rde" :foreground "#4db5bd")
(rainbow-delimiters-depth-6-face :short "rd-6" :slug "rdf" :foreground "#4078f2")
(rainbow-delimiters-depth-7-face :short "rd-7" :slug "rdg" :foreground "#a626a4")
(rainbow-delimiters-depth-8-face :short "rd-8" :slug "rdh" :foreground "#50a14f")
(rainbow-delimiters-depth-9-face :short "rd-9" :slug "rdi" :foreground "#b751b6")))

View File

@ -0,0 +1,44 @@
#!/usr/bin/env sh
":"; exec emacs --quick --script "$0" -- "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
(setq log-file (expand-file-name (format "%s-log.txt" (file-name-base load-file-name))))
(load (expand-file-name "initialise.el" (file-name-directory load-file-name)) nil t)
(initialise 'light)
;;; Actually do the exporting now
(message "[34] Engraving files")
;; For some reason, these seem to behave a bit strangely.
(add-load-path! "~/.config/emacs/.local/straight/repos/parent-mode/"
"~/.config/emacs/.local/straight/repos/highlight-quoted/")
(require 'highlight-numbers)
(require 'highlight-quoted)
(require 'rainbow-delimiters)
(require 'engrave-faces-html)
(load (expand-file-name "doom-one-light-engraved-theme.el"))
(engrave-faces-use-theme 'doom-one-light)
(defvar files-to-engrave
'("init.el" "config.el" "packages.el" "config.org"))
(when (member "org" (mapcar #'file-name-extension files-to-engrave))
(when (assoc 'org after-load-alist)
(setcdr (assoc 'org after-load-alist) nil))
(setq org-load-hook nil)
(require 'org)
(setq org-mode-hook nil))
(let ((default-directory config-root))
(dolist (file files-to-engrave)
(engrave-faces-html-file file)))
(publish '("*.html" . "engraved"))
(message "[1;32] Engraving complete!")
(setq inhibit-message t)
(kill-emacs exit-code)

View File

@ -51,7 +51,7 @@
(replace-match ",#+"))
(buffer-string))
"\n#+end_src"))
(directory-files (concat snippets s-mode) t "[^.]$")
(directory-files (file-name-concat snippets s-mode) t "^[^.]")
"\n\n")))
(directory-files snippets nil "^[^.]+$")
(directory-files snippets nil "^[^.]")
"\n\n")))

View File

@ -1,62 +0,0 @@
#!/usr/bin/env sh
":"; exec script -eqfc "TERM=xterm-direct emacs --quick -nw --eval '(load (expand-file-name \"$0\"))' && rm typescript" 1>/dev/null # -*- mode: emacs-lisp; lexical-binding: t; -*-
(defvar files-to-htmlize '("init.el" "config.el" "packages.el"))
(defvar htmlize-theme 'doom-one-light)
;; Setup
(setq log-file (format "%s-log.txt" (file-name-base load-file-name)))
(load (expand-file-name "initialise.el" (file-name-directory load-file-name)))
(initialise)
(defun my-debugger (err &rest debugger-args)
(message "\033[0;31mERROR: %s\nBACKTRACE: %s\033[0m"
debugger-args
(with-temp-buffer
(let ((standard-output (current-buffer)))
(backtrace)
(buffer-string))))
(kill-emacs 1))
(setq debugger #'my-debugger)
;; Start htmlizing
(require 'htmlize)
(defun my-htmlize-file (file)
(message "Htmlizing %s" file)
(let ((output-file (expand-file-name
(htmlize-make-file-name (file-name-nondirectory file))
(file-name-directory file))))
(with-current-buffer (find-file-literally file)
(normal-mode)
(font-lock-ensure)
(set-buffer-modified-p nil)
(with-current-buffer (htmlize-buffer-1)
(goto-char (point-min))
(replace-string "</title>\n"
"</title>
<style>
body > pre {
font-size: 1rem;
max-width: min(100rem, 100%);
width: max-content;
white-space: pre-wrap;
margin: auto;
}
</style>\n")
(let ((inhibit-message t))
(write-file output-file)
(publish output-file)
(kill-buffer (current-buffer))))
(kill-buffer (current-buffer)))))
(load-theme htmlize-theme t)
(dolist (file files-to-htmlize)
(my-htmlize-file (expand-file-name file config-root)))
(setq inhibit-message t)
(kill-emacs exit-code)

View File

@ -10,15 +10,18 @@
(directory-file-name
(file-name-directory load-file-name))))))
;;; Report errors
(setq debug-on-error t
doom-debug-p t)
(add-to-list 'load-path ; Allow require-ing subconf modules.
(expand-file-name "subconf" config-root))
(defvar log-file "unnamed-log.txt")
(write-region "" nil log-file)
(setq print-level nil
print-length nil
print-escape-newlines t
print-quoted t)
;;; Messaging
(defvar log-messages t)
@ -58,23 +61,28 @@
args)))))
(when message-colour
(advice-add 'debug :around #'red-error)
(advice-add 'message :around #'timed-coloured-message)
(advice-add 'doom--print :around #'timed-coloured-message))
(advice-add 'debug :around #'red-error))
;; (advice-add 'message :around #'timed-coloured-message))
;; (advice-add 'doom--print :around #'timed-coloured-message))
;;; Initialisation
(defun initialise (&optional full)
(defun initialise (&optional mode)
(advice-add 'theme-magic-from-emacs :override #'ignore)
(advice-add 'format-all-buffer :override #'ignore)
(if full
(load (expand-file-name "~/.emacs.d/init.el"))
(setq gc-cons-threshold 16777216
gcmh-high-cons-threshold 16777216)
(load (expand-file-name "core/core.el" user-emacs-directory) nil t)
(require 'core-cli)
(doom-initialize))
(pcase mode
('full
(load "~/.config/emacs/early-init.el")
(require 'doom-start)
(require 'flycheck) ; To avoid issues that crop up with org-flycheck.
(defmacro flycheck-prepare-emacs-lisp-form (&rest _)))
('light
(setq gc-cons-threshold 16777216
gcmh-high-cons-threshold 16777216)
(load "~/.config/emacs/lisp/doom.el")
(require 'doom-cli)
(doom-initialize-packages)))
(setq doom-cli-log-error-file log-file)
(write-region "" nil log-file nil :silent)
@ -83,10 +91,12 @@
(advice-add 'ask-user-about-supersession-threat :override #'ignore)
(setq debug-on-error t
doom-debug-p t)
(add-hook! 'doom-debug-mode-hook
(explain-pause-mode -1))
(setq emojify-download-emojis-p t)
(setq emojify-download-emojis-p nil)
(unless (boundp 'image-types) ; why on earth is this needed?
(setq image-types '(svg png gif tiff jpeg xpm xbm pbm)))
@ -109,19 +119,38 @@
(make-directory dir t))
(push dir known-existing-dirs))))
(require 'dired)
(defun publish (&rest files)
"Move each file into `publish'.
Names containing \"*\" are treated as a glob."
(dolist (file files)
(if (string-match-p "\\*" file)
(apply #'publish
(directory-files (expand-file-name (or (file-name-directory file) "./") config-root)
t
(dired-glob-regexp (file-name-nondirectory file))))
(unless (string-match-p "/\\.\\.?$" file)
(message (concat (when message-colour "[34] ") "Publishing %s") file)
(let ((target (replace-regexp-in-string (regexp-quote config-root)
publish-dir
(expand-file-name file config-root))))
(ensure-dir-exists target)
(copy-file (expand-file-name file config-root) target t))))))
Names containing \"*\" are treated as a glob.
In addition to strings, files may also be a (glob . target-dir) cons cell."
(message "files: %S" files)
(let (uproot)
(when (eq (car files) :uproot)
(setq uproot t)
(pop files))
(dolist (file files)
(if (consp file)
(let ((publish-dir (file-name-as-directory (expand-file-name (cdr file) publish-dir))))
(if uproot
(publish :uproot (car file))
(publish (car file))))
(if (string-match-p "\\*" file)
(apply #'publish
(append
(and uproot (list :uproot))
(directory-files (expand-file-name (or (file-name-directory file) "./") config-root)
t
(dired-glob-regexp (file-name-nondirectory file)))))
(unless (string-match-p "/\\.\\.?$" file)
(let ((target (if uproot
(expand-file-name (file-name-nondirectory file) publish-dir)
(replace-regexp-in-string (regexp-quote config-root)
publish-dir
(expand-file-name file config-root)))))
(message (concat (when message-colour "[34] ") "Publishing %s -> %s")
(replace-regexp-in-string (regexp-quote config-root) "" file)
(replace-regexp-in-string (regexp-quote config-root) "" target))
(ensure-dir-exists target)
(copy-file (expand-file-name file config-root) target t))))))))

View File

@ -4,7 +4,7 @@
(setq log-file (expand-file-name (format "%s-log.txt" (file-name-base load-file-name))))
(load (expand-file-name "initialise.el" (file-name-directory load-file-name)) nil t)
(initialise t)
(initialise 'full)
;;; Actually do the exporting now
@ -23,7 +23,8 @@
(with-temp-buffer
(let ((default-directory config-root)
(buffer-file-name (expand-file-name "config.org" config-root))
(org-export-coding-system org-html-coding-system)
(org-export-coding-system 'utf-8)
(org-export-with-broken-links t)
org-mode-hook org-load-hook)
(insert-file-contents (expand-file-name "config.org" config-root))
(goto-char (point-max))

View File

@ -4,7 +4,7 @@
(setq log-file (expand-file-name (format "%s-log.txt" (file-name-base load-file-name))))
(load (expand-file-name "initialise.el" (file-name-directory load-file-name)) nil t)
(initialise t)
(initialise 'full)
;;; Actually do the exporting now
@ -15,8 +15,6 @@
(require 'org)
(require 'ox-latex)
(require 'emojify) ; this should not be needed
(advice-add 'pdf-tools-install :around #'ignore)
(advice-add 'pdf-info-features :around #'ignore)
@ -29,11 +27,17 @@
(require 'highlight-quoted)
(require 'rainbow-delimiters)
(setq org-mode-hook nil)
(require 'engrave-faces-latex)
(load (expand-file-name "doom-one-light-engraved-theme.el"))
(engrave-faces-use-theme 'doom-one-light)
(with-temp-buffer
(let ((default-directory config-root)
(buffer-file-name (expand-file-name "config.org" config-root))
(org-export-coding-system org-html-coding-system)
(org-export-coding-system 'utf-8)
(org-export-with-broken-links t)
(org-resource-download-policy t)
(org-persist-disable-when-emacs-Q nil)
org-mode-hook org-load-hook)
(insert-file-contents (expand-file-name "config.org" config-root))
(goto-char (point-max))
@ -41,9 +45,9 @@
(message "[33] Exporting %s" (buffer-file-name))
(org-mode)
;; There isn't actually any Julia code in config.org
(setq org-latex-conditional-features
(delq (rassq 'julia-code org-latex-conditional-features)
org-latex-conditional-features))
(setq org-export-conditional-features
(delq (rassq 'julia-code org-export-conditional-features)
org-export-conditional-features))
(org-latex-export-to-pdf)))
(publish "config.pdf")

View File

@ -13,7 +13,7 @@
(load (expand-file-name "async-proc-management.el") nil t)
(apm-exec '("htmlize.sh")) ; "check-package-updates.sh"))
(apm-exec '("subconf.sh" "engrave.sh"))
(if (not (file-exists-p (concat user-emacs-directory "xkcd/")))
(apm-exec "org-html.sh" :then "org-pdf.sh")
@ -21,6 +21,8 @@
(apm-wait-and-monitor)
(publish :uproot (cons (format "%s*-log.txt" (file-name-directory load-file-name)) "logs"))
(if (= 0 exit-code)
(message "[1;32] Config publish content generated!%s" (apm-space-fill-line 33))
(message "[1;31] Config publishing aborted%s" (apm-space-fill-line 25)))

View File

@ -0,0 +1,37 @@
#!/usr/bin/env sh
":"; exec emacs --quick --script "$0" -- "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
(setq log-file (expand-file-name (format "%s-log.txt" (file-name-base load-file-name))))
(load (expand-file-name "initialise.el" (file-name-directory load-file-name)) nil t)
(initialise 'light)
;;; Actually do the exporting now
(message "[34] Publishing raw subconf files")
(publish "subconf/*.el")
;;; Engraving
;; For some reason, these seem to behave a bit strangely.
(add-load-path! "~/.config/emacs/.local/straight/repos/parent-mode/"
"~/.config/emacs/.local/straight/repos/highlight-quoted/")
(require 'highlight-numbers)
(require 'highlight-quoted)
(require 'rainbow-delimiters)
(require 'engrave-faces-html)
(load (expand-file-name "doom-one-light-engraved-theme.el"))
(engrave-faces-use-theme 'doom-one-light)
(dolist (subconf-file (directory-files (expand-file-name "subconf" config-root) t "\\.el$"))
(engrave-faces-html-file subconf-file))
(publish '("subconf/*.html" . "engraved"))
(message "[1;32] Subconf publish complete!")
(setq inhibit-message t)
(kill-emacs exit-code)