feat: replace 由麻 => 由真 #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Release, and Deploy | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: | |
group: pages | |
cancel-in-progress: false | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.6.0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm i --frozen-lockfile | |
- name: Build | |
run: | | |
pnpm build | |
ls -l dist/epub | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: dist/docs | |
- name: Configure Git | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Bump version | |
id: bump_version | |
run: | | |
# 获取最新的 tag | |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
# 提取版本号并增加 patch 版本 | |
CURRENT_VERSION=${LATEST_TAG#v} | |
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
MAJOR=${VERSION_PARTS[0]} | |
MINOR=${VERSION_PARTS[1]} | |
PATCH=$((VERSION_PARTS[2] + 1)) | |
NEW_VERSION="v$MAJOR.$MINOR.$PATCH" | |
git add . | |
git commit -m "Build for release" || echo "No changes to commit" | |
git tag -a $NEW_VERSION -m "Bump version to $NEW_VERSION" | |
echo "new_version=${NEW_VERSION#v}" >> $GITHUB_OUTPUT | |
env: | |
GIT_AUTHOR_NAME: github-actions[bot] | |
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com | |
GIT_COMMITTER_NAME: github-actions[bot] | |
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com | |
- name: Push changes | |
run: git push --follow-tags | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.bump_version.outputs.new_version }} | |
release_name: Release ${{ steps.bump_version.outputs.new_version }} | |
draft: false | |
prerelease: false | |
- name: Create Release and Upload Assets | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ steps.bump_version.outputs.new_version }} | |
name: Release ${{ steps.bump_version.outputs.new_version }} | |
body: | | |
Release epub for version ${{ steps.bump_version.outputs.new_version }} | |
files: | | |
./dist/books.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: build-and-release | |
runs-on: ubuntu-latest | |
name: Deploy | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |