Skip to content

Commit

Permalink
ci: update
Browse files Browse the repository at this point in the history
  • Loading branch information
rxliuli committed Aug 10, 2024
1 parent 6c62623 commit 7ac138b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 66 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/node.js.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
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

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Prepare docs for Pages
run: |
touch dist/docs/.nojekyll
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: dist/docs

- name: Get current version
id: get_version
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"

- name: Bump version
id: bump_version
run: |
git status
npm version patch -m "Bump version to %s"
echo "::set-output name=new_version::$(node -p "require('./package.json').version")"
- 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: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/epub/*.epub
asset_name: ebook.epub
asset_content_type: application/epub+zip

- name: Push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git push --follow-tags
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Production
/build
dist/
.pnpm-store/

# Generated files
.docusaurus
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "to-the-stars",
"private": true,
"type": "module",
"version": "1.0.0",
"version": "1.7.0",
"scripts": {
"build": "mark-magic && jszip-cli add dist/epub -o dist/books.zip -f",
"build-docs": "mark-magic --task docs",
Expand Down

0 comments on commit 7ac138b

Please sign in to comment.