From 9859b298700a2dfc3c639529268ee244db478aff Mon Sep 17 00:00:00 2001 From: Kimikazu Kato Date: Tue, 30 May 2023 01:09:21 +0900 Subject: [PATCH] First commit --- .github/workflows/actions-docker.yml | 62 ++++++++++++++++++++++++++++ Dockerfile | 12 ++++++ README.md | 7 +++- build/.gitkeep | 0 docker-compose.yml | 8 ++++ tex/build.sh | 8 ++++ tex/sample.tex | 8 ++++ 7 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/actions-docker.yml create mode 100644 Dockerfile create mode 100644 build/.gitkeep create mode 100644 docker-compose.yml create mode 100644 tex/build.sh create mode 100644 tex/sample.tex diff --git a/.github/workflows/actions-docker.yml b/.github/workflows/actions-docker.yml new file mode 100644 index 0000000..04e4339 --- /dev/null +++ b/.github/workflows/actions-docker.yml @@ -0,0 +1,62 @@ +name: typeset +on: + push: + branches: + - main + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: get current date + id: date + run: | + echo "date=$(TZ=TIME_ZONE date +'%Y%m%d')" >$GITHUB_OUTPUT + - name: get counter + id: counter + run: | + LAST_RELEASE=$(gh release view --json=tagName | jq -r '.tagName') + LAST_DATE=$(echo $LAST_RELEASE|sed 's/-.*$//') + LAST_COUNTER=$(echo $LAST_RELEASE|sed 's/.*-*//') + if [ "$LAST_DATE" = "$DATE" ] + then + echo "counter=$(($LAST_COUNTER +1))" >$GITHUB_OUTPUT + else + echo "counter=1" >$GITHUB_OUTPUT + fi + env: + DATE: ${{ steps.date.outputs.date }} + GH_TOKEN: ${{ github.token }} + TIME_ZONE: JST-9 # Specify time zone here + - name: get version + id: version + run: | + echo "version=${{ steps.date.outputs.date }}-${{ steps.counter.outputs.counter }}" >$GITHUB_OUTPUT + - name: buildx + uses: docker/setup-buildx-action@v1 + - name: build + run: docker-compose build + - name: run tex + run: docker-compose run tex + - name: release + uses: actions/create-release@v1 + id: create_release + with: + draft: false + prerelease: false + release_name: Release ${{ steps.version.outputs.version }} + tag_name: ${{ steps.version.outputs.version }} + env: + GITHUB_TOKEN: ${{ github.token }} + - name: upload asset + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./build/sample.pdf # The resulting pdf file + asset_name: sample-${{ steps.version.outputs.version }}.pdf + asset_content_type: application/zip diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b825c46 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM blang/latex:ubuntu + +RUN apt update -y +RUN apt install -y tzdata + +RUN mkdir /work +RUN mkdir /work/build +COPY ./tex /work + +WORKDIR /work + +CMD sh ./build.sh diff --git a/README.md b/README.md index 11df6aa..9ecacb1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # streamlined_latex_compilation -Book Writing Platform: Streamlined Latex Compilation + +This is a sophisticated book writing platform. Whenever you push files to the main branch on GitHub, the system automatically compiles them and uploads the resulting PDF file to the release page. + +The resulting PDF file is named in the following format: "sample-yyyymmdd-i", where "yyyymmdd" represents the date, and "i" is a sequential number within that date. + +To give it a try, you can fork this project, make modifications to the included LaTeX file, and push your changes. diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..944dead --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + tex: + build: . + volumes: + - type: bind + source: ./build + target: /work/build + diff --git a/tex/build.sh b/tex/build.sh new file mode 100644 index 0000000..7b4611f --- /dev/null +++ b/tex/build.sh @@ -0,0 +1,8 @@ +TEXFILE=sample.tex +FILE=${TEXFILE%.*} +TEX=lualatex +echo $FILE +$TEX $TEXFILE -interaction=nonstopmode +$TEX $TEXFILE -interaction=nonstopmode +$TEX $TEXFILE -interaction=nonstopmode +cp ${FILE}.pdf ./build diff --git a/tex/sample.tex b/tex/sample.tex new file mode 100644 index 0000000..165580f --- /dev/null +++ b/tex/sample.tex @@ -0,0 +1,8 @@ +\documentclass{article} +\usepackage[ipa]{luatexja-preset} +\title{Sample} +\author{Kimikazu Kato} +\begin{document} +\maketitle +これはサンプルです。 +\end{document}