diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b3612c9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Convert Markdown to PDF and Create Release + +on: + workflow_dispatch: # 手動実行を有効にする + push: + branches: + - feature/#6 # デバッグ用 + +jobs: + convert_and_release: + runs-on: ubuntu-latest + + steps: + # リポジトリをチェックアウト + - name: Checkout repository + uses: actions/checkout@v2 + + # pandocをインストール + - name: Install pandoc + run: sudo apt-get install pandoc + + # Markdownファイルのタイトルを抽出 + - name: Extract title from Markdown + id: extract_title + run: | + TITLE=$(head -n 1 constitution.md | sed 's/^# //') + echo "TITLE=$TITLE" >> $GITHUB_ENV + echo "Extracted title: $TITLE" + + # MarkdownからLaTeXファイルに変換 + - name: Convert Markdown to LaTeX + run: | + pandoc -r markdown-auto_identifiers constitution.md -o constitution.tex --template=template.tex -V title="$TITLE" + + # 生成されたLaTeXファイルを表示 + - name: Display constitution.tex content + run: cat constitution.tex + + # LuaLaTeXでPDFを生成 + - name: Compile LaTeX to PDF using LuaLaTeX + run: | + docker run --rm -v $PWD:/workdir paperist/alpine-texlive-ja lualatex -output-directory=/workdir /workdir/constitution.tex + + # 現在時刻を取得 + - name: Set current datetime as env variable + env: + TZ: 'Asia/Tokyo' # タイムゾーン指定 + run: echo "CURRENT_DATETIME=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV + + # Releaseの作成 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "release-${{ github.sha }}-${{ github.run_id }}" + release_name: "Release ${{ env.CURRENT_DATETIME }}" + body: | + Compiled PDF + draft: false + prerelease: false + + # 生成されたPDFをReleaseにアップロード + - name: Upload Release Asset + id: upload_release_asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./constitution.pdf + asset_name: constitution.pdf + asset_content_type: application/pdf diff --git a/template.tex b/template.tex new file mode 100644 index 0000000..e5ed331 --- /dev/null +++ b/template.tex @@ -0,0 +1,26 @@ +\documentclass{ltjsarticle} +\usepackage[top=25truemm, bottom=25truemm, left=20truemm, right=20truemm]{geometry} % 余白設定 +\usepackage[utf8]{inputenc} % UTF-8エンコーディングを使用 +\usepackage[japanese]{babel} % 日本語のサポートを有効にする +\usepackage{luatexja-preset} % 日本語サポートを有効化 + +% 目次やリストのレイアウト調整 +\def\tightlist{\itemsep1pt\parskip0pt\parsep0pt} % リストの間隔を調整 + +% タイトル設定 +\title{$title$} % Markdownで定義されたタイトルを挿入 + +% セクション設定(デフォルトの \section ではなく、指定された \section を使う) +\renewcommand{\section}[1]{\vspace{10pt}\noindent \textbf{\large #1}} % セクションの書式変更 + +% サブセクション設定(デフォルトの \subsection を使用しない) +\renewcommand{\subsection}[1]{\vspace{8pt}\noindent \textbf{#1}} % サブセクションの書式変更 + +\begin{document} + +\maketitle % タイトルを出力 + +% 本文部分 +$body$ + +\end{document}