Skip to content

Commit ef4ee55

Browse files
committed
Add GitHub Pages setup.
1 parent d6a76ef commit ef4ee55

7 files changed

Lines changed: 466 additions & 381 deletions

File tree

‎.envrc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ envrc=$(find_up .envrc)
2727
export ROOT_DIR=${envrc%/.envrc}
2828

2929
export REFS_JA_PATH=$PWD/translation/refs.ja.yaml
30+
31+
export USE_GUIX=yes

‎.github/workflows/pages.yaml‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and deploy to GitHub Pages
2+
on:
3+
push:
4+
branches: [ "ja" ]
5+
pull_request:
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: "pages"
10+
cancel-in-progress: false
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Pages
20+
id: pages
21+
uses: actions/configure-pages@v5
22+
23+
- name: Install dependencies
24+
run: |
25+
sudo apt update
26+
sudo apt install --yes \
27+
lua5.3 luarocks liblua5.3-dev libyaml-dev libcmark-dev cpanminus po4a
28+
29+
- name: Install CommonMark Perl module
30+
run: |
31+
sudo cpanm CommonMark
32+
33+
- name: Install LuaRocks
34+
run: |
35+
./translation/bin/install
36+
37+
- name: Install Ruby
38+
uses: ruby/setup-ruby@v1
39+
with:
40+
ruby-version: '3.4'
41+
42+
- name: Build pages
43+
# Run twice to correctly reflect link references
44+
run: |
45+
eval "$(luarocks path --bin)"
46+
export REFS_JA_PATH=$PWD/translation/refs.ja.yaml
47+
echo "---\n" > translation/refs.translatable.yaml
48+
git clone https://github.com/mquinson/po4a
49+
export PERL5LIB="$PWD/po4a/lib:$PERL5LIB"
50+
make --directory translation
51+
touch translation/po4a.cfg
52+
make --directory translation
53+
54+
- name: Upload Pages artifact
55+
uses: actions/upload-pages-artifact@v3
56+
with:
57+
path: translation/ja/spec.html
58+
59+
deploy:
60+
if: github.ref == 'refs/heads/ja'
61+
needs: build
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
uses: actions/deploy-pages@v4
66+
permissions:
67+
id-token: write
68+
pages: write
69+
environment:
70+
name: github-pages
71+
url: ${{ steps.deployment.outputs.page_url }}

‎tools/make_spec.lua‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ local lyaml = require('lyaml')
44

55
local format = arg[1] or 'html'
66

7-
-- io.stderr:write(os.getenv("PWD"))
7+
local jarefs = {}
88
local jarefs_file = io.open(os.getenv("REFS_JA_PATH", "r"))
9-
if not jarefs_file then
10-
io.stderr:write("WARNING: ja refs file not open\n")
11-
os.exit(1)
9+
if jarefs_file then
10+
jarefs = lyaml.load(jarefs_file:read("a"))
11+
jarefs_file:close()
12+
else
13+
io.stderr:write("WARNING: ja refs file not open. Please rerun\n")
1214
end
13-
local jarefs = lyaml.load(jarefs_file:read("a")) or {}
14-
jarefs_file:close()
1515

1616
local trim = function(s)
1717
return s:gsub("^%s+",""):gsub("%s+$","")

‎translation/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PO4A ?= po4a
12
outdir := ja
23

34
all: ${outdir}/spec.txt \
@@ -25,7 +26,7 @@ ${outdir}/spec.txt: po/ja.po po/en.pot po4a.cfg
2526
translate: credit.md
2627
cp ../spec.txt spec.txt
2728
lua ../tools/make_spec.lua refblock < ../spec.txt >> spec.txt
28-
po4a po4a.cfg
29+
$(PO4A) po4a.cfg
2930
.PHONY: translate
3031

3132
po/en.pot:

‎translation/bin/install‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/bin/sh
22
set -eu
3+
34
luarocks install --local lcmark
4-
luarocks install --local lyaml "YAML_LIBDIR=$YAML_LIBDIR"
5+
6+
if [ "${USE_GUIX:-}" = yes ]
7+
then
8+
luarocks install --local lyaml "YAML_LIBDIR=$YAML_LIBDIR"
9+
else
10+
luarocks install --local lyaml
11+
fi

‎translation/generate-translated-refs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/bin/env ruby
22
require "yaml"
33

4-
doc = YAML.load_file(File.join(__dir__, "refs.translatable.ja.yaml"))
4+
doc = {}
5+
path = File.join(__dir__, "refs.translatable.ja.yaml")
6+
if File.file?(path)
7+
doc.replace(YAML.load_file(path))
8+
end
59
refs = {}
6-
doc&.each do |entry|
10+
doc.each do |entry|
711
# entry has en, id, ja
812
ja = entry["ja"]
913
refs[ja] and raise "duplicated entry: #{entry.inspect}"

0 commit comments

Comments
 (0)