Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: 使用 semantic-release 自动发布电子书
Browse files Browse the repository at this point in the history
Co-authored-by: 北雁 Cryolitia <[email protected]>
Zh40Le1ZOOB and Cryolitia committed Mar 26, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent 3fae478 commit 7c3cc77
Showing 6 changed files with 6,328 additions and 424 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/build.yml → .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Build and deploy
name: Build and publish

on:
workflow_dispatch:
push:
branches:
- 'main'
- "main"
paths:
- ".github/**"
- ".vitepress/**"
@@ -14,46 +15,51 @@ on:
- "package.json"

permissions:
pages: write
id-token: write
contents: write
issues: write
pull-requests: write

concurrency:
group: "pages"
group: "build"
cancel-in-progress: true

jobs:
build:
name: Build and deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Setup Node.js environment
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: current
cache: npm

- name: Install node packages
run: npm ci

- name: Install mdBook
uses: baptiste0928/cargo-install@v2
with:
crate: mdbook
git: https://github.com/rust-lang/mdBook

- name: Install mdbook-epub
uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-epub
git: https://github.com/Michael-F-Bryan/mdbook-epub

- name: Install mdbook-typst-pdf
uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-typst-pdf
git: https://github.com/KaiserY/mdbook-typst-pdf

- name: Install fonts
run: |
mkdir -p ~/.local/share/fonts/
@@ -81,12 +87,29 @@ jobs:
curl -sL -o times_sans_serif.zip https://dl.dafont.com/dl/?f=times_sans_serif
unzip times_sans_serif.zip -d ~/.local/share/fonts/times_sans_serif
fc-cache -rv
- name: Install Calibre
run: |
sudo apt install -y libegl1 libopengl0 libxcb-cursor0
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
- name: Build
env:
NODE_OPTIONS: --max_old_space_size=4096
run: |
sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md
npm run build
ebook-convert .vitepress/dist/药娘的天空.epub .vitepress/dist/药娘的天空.mobi
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }}
projectName: proskynova-github-io
directory: .vitepress/dist/
wranglerVersion: 3

- name: Release eBook
env:
GITHUB_TOKEN: ${{ github.token }}
run: npx semantic-release
37 changes: 0 additions & 37 deletions .github/workflows/publish.yaml

This file was deleted.

53 changes: 53 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
branches:
- main
plugins:
- - "@semantic-release/commit-analyzer"
- releaseRules:
- type: feat
release: minor
- type: fix
release: minor
- type: refactor
release: patch
- type: style
release: patch
- type: typo
release: patch
- type: grammar
release: patch
- type: ambig
release: patch
- type: punctua
release: patch
- "@semantic-release/release-notes-generator"
- - "@semantic-release/github"
- assets:
- path: book/epub/药娘的天空.epub
name: transky-${nextRelease.version}.epub
- path: book/mobi/药娘的天空.mobi
name: transky-${nextRelease.version}.mobi
- path: book/typst-pdf/药娘的天空.pdf
name: transky-${nextRelease.version}.pdf
preset: conventionalcommits
presetConfig:
- types:
- type: feat
section: Features
- type: fix
section: Bug Fixes
- type: refactor
hidden: true
- type: style
section: Style Improvements
- type: typo
section: Typo Fixes
- type: grammar
section: Grammar Fixes
- type: ambig
section: Ambiguity Fixes
- type: punctua
section: Punctuation Fixes
- type: chore
hidden: true
- type: ci
hidden: true
6,600 changes: 6,230 additions & 370 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -5,13 +5,15 @@
},
"devDependencies": {
"sass": "^1.70.0",
"semantic-release": "^23.0.5",
"vitepress": "^1.0.0-rc.36",
"vitepress-sidebar": "^1.18.6"
},
"scripts": {
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview",
"build": "npm run docs:build && find src/ -type f -name \"*.md\" ! -path \"src/index.md\" -exec sed -i \"/^---$/,/^---$/d\" {} \\; && mdbook build && cp book/epub/药娘的天空.epub .vitepress/dist/ && cp book/typst-pdf/药娘的天空.pdf .vitepress/dist/"
"web:dev": "vitepress dev",
"web:build": "vitepress build",
"web:preview": "vitepress preview",
"ebook:build": "find src/ -type f -name \"*.md\" ! -path \"src/index.md\" -exec sed -i \"/^---$/,/^---$/d\" {} \\; && mdbook build && mkdir book/mobi/ && ebook-convert book/epub/药娘的天空.epub book/mobi/药娘的天空.mobi",
"build": "npm run web:build && npm run ebook:build"
}
}
3 changes: 3 additions & 0 deletions src/index.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@ hero:
- theme: brand
text: 开始阅读
link: /foreword
- theme: brand
text: 下载电子书
link: https://github.com/proskynova/proskynova.github.io/releases/latest
- theme: alt
text: 在 GitHub 上查看
link: https://github.com/proskynova

0 comments on commit 7c3cc77

Please sign in to comment.