This commit is contained in:
2023-10-14 23:53:13 +09:00
parent 9cc27bf05a
commit c93b9df9de
5 changed files with 38 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules node_modules
_book _book
target

View File

@ -1,6 +1,30 @@
stages:
- build
- upload
- release
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/devlifefrommodernway/${CI_COMMIT_TAG}"
upload:
stage: upload
image: curlimages/curl:latest
rules:
- if: $CI_COMMIT_TAG
script:
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/book-${CI_COMMIT_TAG}.pdf ${PACKAGE_REGISTRY_URL}/book-${CI_COMMIT_TAG}.pdf'
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- 'release-cli create --name "book-$CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG --assets-link "{\"name\":\"book-${CI_COMMIT_TAG}\", \"url\":\"${PACKAGE_REGISTRY_URL}/book-${CI_COMMIT_TAG}\"}"'
image: node:lts-bullseye image: node:lts-bullseye
pages: pages:
stage: deploy stage: build
cache: cache:
key: key:
files: files:
@ -9,15 +33,22 @@ pages:
- node_modules/ - node_modules/
script: script:
- apt-get update && apt-get install -y calibre --no-install-recommends - apt-get update && apt-get install -y calibre --no-install-recommends
- apt-get update && apt-get install -y fontconfig unzip sudo - apt-get update && apt-get install -y fontconfig unzip sudo
- unzip "./fonts/*.zip" -d /usr/share/fonts/ - unzip "./fonts/*.zip" -d /usr/share/fonts/
&& fc-cache -fv && fc-cache -fv
- sudo corepack enable - sudo corepack enable
- sudo -u node pnpm install - sudo -u node pnpm install
- sudo -u node env LANG=ja_JP.UTF-8 pnpm run build - sudo -u node env LANG=ja_JP.UTF-8 pnpm run build
- cp -a _book/ public/webbook/
- mv target/book{.pdf,-${CI_COMMIT_TAG}.pdf}
- mv target/book{.epub,-${CI_COMMIT_TAG}.epub}
- mv target/book{.mobi,-${CI_COMMIT_TAG}.mobi}
- cp -a _book/. public/
artifacts: artifacts:
paths: paths:
- public/ - public/
rules: rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_TAG

View File

@ -7,9 +7,9 @@
"build": "run-s build:content", "build": "run-s build:content",
"build:content": "run-p build:content:*", "build:content": "run-p build:content:*",
"build:content:web": "honkit build", "build:content:web": "honkit build",
"build:content:pdf": "honkit pdf . ./public/books/book.pdf", "build:content:pdf": "honkit pdf . ./target/book.pdf",
"build:content:epub": "honkit epub . ./public/books/book.epub", "build:content:epub": "honkit epub . ./target/book.epub",
"build:content:mobi": "honkit mobi . ./public/books/book.mobi" "build:content:mobi": "honkit mobi . ./target/book.mobi"
}, },
"devDependencies": { "devDependencies": {
"gitbook-plugin-anchors": "^0.7.1", "gitbook-plugin-anchors": "^0.7.1",

0
public/.gitkeep Normal file
View File

View File

@ -1,2 +0,0 @@
*
!.gitignore