Skip to content

Commit

Permalink
Merge pull request #3 from kmc-jp/2021-summer
Browse files Browse the repository at this point in the history
2021 summerの更新のバックポート( Fixes #1 )
  • Loading branch information
ikubaku authored Nov 16, 2021
2 parents daa5182 + 73d784e commit 6d2f91d
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 9 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: build bushi
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: build pdf
run: docker run --mount type=bind,source="$(pwd)",target=/workdir ghcr.io/kmc-jp/bushi-build-image:latest
- name: save log
uses: actions/upload-artifact@v2
with:
name: log
path: out/*.log
- name: save artifact
uses: actions/upload-artifact@v2
with:
name: bushi.pdf
path: out/bushi.pdf
if-no-files-found: error
28 changes: 28 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: build and push bushi build image
on:
push:
tags:
- 'image/*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: get tag
id: variables
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Check out the repo
uses: actions/checkout@v2
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container image
uses: docker/build-push-action@v2
with:
context: docker
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/bushi-build-image:latest
ghcr.io/${{ github.repository_owner }}/bushi-build-image:${{ steps.variables.outputs.tag }}
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build bushi and make release on tag pushed
on:
push:
tags:
- 'rel/*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: get tag
id: variables
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Check out the repo
uses: actions/checkout@v2
- name: build pdf
run: docker run --mount type=bind,source="$(pwd)",target=/workdir ghcr.io/kmc-jp/bushi-build-image:latest
- name: save log
uses: actions/upload-artifact@v2
with:
name: log
path: out/*.log
- name: save artifact
uses: actions/upload-artifact@v2
with:
name: bushi.pdf
path: out/bushi.pdf
if-no-files-found: error
- name: create release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ steps.variables.outputs.tag }}
prerelease: false
title: ${{ steps.variables.outputs.tag }}
files: |
out/bushi.pdf
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,39 @@ Xで出す部誌のリポジトリ
----

# タイプセットする方法
TODO: dockerを使ったタイプセットの説明を書く
dockerだと
```
docker run --mount type=bind,source="$(pwd)",target=/workdir ghcr.io/kmc-jp/bushi-build-image:latest
```

そうでない時は単に
```
$ ruby build.rb
```

- TeXLive, ruby, pandoc(ver. 2)のインストールが必要です

## CIによるタイプセット
レポジトリにpushすると、CIによりタイプセットが行なわれて、pdfが自動で生成されます。
正常にタイプセットできた場合、GitHub Actionsのrun結果のページを開くと、
artifactにbushi.pdfという項目があります。
[![Image from Gyazo](https://i.gyazo.com/9cc637c1b1db1eff9e169585df6fcaca.png)](https://gyazo.com/9cc637c1b1db1eff9e169585df6fcaca)

これは、.github/workflows/build.yamlにて行なっています。

## dockerのimageの更新方法
.github/workflows/image.yaml でimageを作成しています。
`image/` から始まるtagをpushすると自動で作成されます。

forkした先でtagをpushしても動作するとは思いますが、
ややこしいので https://github.com/kmc-jp/bushi-template2 へのtagのpushで作成して欲しいです。

https://github.com/kmc-jp/bushi-template2/pkgs/container/bushi-build-image にimageのリストがあります。

## 記事のタグ
.github/workflows/release.yaml で `rel/` から始まるタグがpushされた際にreleaseを作成しています。
こちらは、imageとは異なり、fork先のレポジトリでリリース版を作成する時とかに使うことを想定しています。

# 記事を書く人へ
記事はMarkdown形式で書いてください。

Expand Down
11 changes: 8 additions & 3 deletions build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
# MarkdownをTeXに変換
Dir.glob('kiji/**/*') do |file|
if FileTest.file? file then
outfile = file.sub(/^kiji\//, '').sub(/.md$/, '.tex')
system("#{PANDOC} -o out/#{outfile} #{file}")
puts $? if $?
next unless file =~ /\.md$/
outfile = file.sub(/^kiji\//, '').sub(/\.md$/, '.tex')
cmd = "#{PANDOC} -o out/#{outfile} #{file}"
puts "exec: #{cmd}"
system(cmd)
puts "exit code: #{$?}" if $?
exit $? if $?.to_i > 0
end
end

Expand All @@ -33,5 +37,6 @@
FileUtils.cd("out") do
system("latexmk -lualatex bushi.tex")
puts $? if $?
exit $? if $?.to_i > 0
end

36 changes: 33 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
FROM arch-texlive-ja
FROM ghcr.io/paperist/texlive-ja:debian

RUN pacman -Sy --noconfirm && \
pacman -S --noconfirm ruby pandoc adobe-source-sans-fonts
RUN apt-get update \
&& apt-get install -y \
ruby \
fontconfig \
fonts-noto-cjk-extra fonts-noto-color-emoji \
xz-utils \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /usr/local/share/fonts/ \
&& cd /tmp \
&& wget https://github.com/adobe-fonts/source-sans/releases/download/3.046R/TTF-source-sans-3.046R.zip -O /tmp/sourceSans.zip \
&& unzip /tmp/sourceSans.zip \
&& wget https://github.com/adobe-fonts/source-code-pro/releases/download/2.038R-ro%2F1.058R-it%2F1.018R-VAR/TTF-source-code-pro-2.038R-ro-1.058R-it.zip -O /tmp/sourceCourde.zip \
&& unzip /tmp/sourceCourde.zip -d /tmp/TTF \
&& mv /tmp/TTF/*.ttf /usr/local/share/fonts/ \
&& wget https://github.com/adobe-fonts/source-han-sans/releases/download/2.004R/SourceHanSansJP.zip -O /tmp/SourceHanSansJP.zip \
&& unzip /tmp/SourceHanSansJP.zip \
&& mv /tmp/SubsetOTF/JP/*.otf /usr/local/share/fonts/ \
&& fc-cache \
&& rm -rf /tmp/*

RUN cd /tmp \
&& wget https://github.com/jgm/pandoc/releases/download/2.16/pandoc-2.16-1-amd64.deb -O pandoc.deb \
&& dpkg -i pandoc.deb \
&& rm -rf /tmp/*

RUN cd /tmp \
&& wget https://github.com/lierdakil/pandoc-crossref/releases/download/v0.3.12.0d/pandoc-crossref-Linux.tar.xz -O pandoc-crossref-Linux.tar.xz \
&& tar xf pandoc-crossref-Linux.tar.xz \
&& chmod +x pandoc-crossref \
&& mv pandoc-crossref /usr/local/bin \
&& rm -rf /tmp/*

RUN tlmgr update --self
RUN tlmgr install adfsymbols ulem lualatex-math
Expand Down
12 changes: 10 additions & 2 deletions luakmcbook.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@
% 改頁なしのinclude等を提供
\usepackage{newclude}

% 絵文字を直接タイプセットしたいので
\directlua{luaotfload.add_fallback
("emojifallback", {
"NotoColorEmoji:mode=harf;"
})
}

% 欧文フォントを変更
\usepackage{fontspec}
\setmainfont[Scale=1]{Linux Libertine O} % セリフ体
\setsansfont[Scale=1.05]{Source Sans Pro} % サンセリフ体
\setmainfont[Scale=1, RawFeature={fallback=emojifallback}]{Linux Libertine O} % セリフ体と絵文字
\setsansfont[Scale=1.05, RawFeature={fallback=emojifallback}]{Source Han Sans JP} % サンセリフ体と絵文字
\setmonofont[Scale=1, RawFeature={fallback=emojifallback}]{Source Code Pro} % 等幅と絵文字

% 校正規約はこれがないと組めなかった
\usepackage{booktabs}
Expand Down

0 comments on commit 6d2f91d

Please sign in to comment.