Skip to content

Commit

Permalink
ci: 使用 semantic-release 自动发布电子书 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zh40Le1ZOOB authored Mar 25, 2024
1 parent 031e13b commit 2f609ed
Show file tree
Hide file tree
Showing 6 changed files with 6,316 additions and 424 deletions.
37 changes: 24 additions & 13 deletions .github/workflows/build.yml → .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Build and deploy
name: Build and publish

on:
push:
branches:
- 'main'
- "main"
paths:
- ".github/**"
- ".vitepress/**"
Expand All @@ -14,26 +14,24 @@ 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
Expand Down Expand Up @@ -86,7 +84,20 @@ jobs:
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:
- test
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
Loading

0 comments on commit 2f609ed

Please sign in to comment.