feat: 初步支持PWA #30
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 | |
on: | |
push: | |
# 由于其它分支为本地测试打包,故只 CI 主线变更 | |
branches: [wu/main] | |
paths-ignore: | |
- '**.md' | |
- '**.txt' | |
- '.github/**' | |
- '!.github/workflows/**' | |
jobs: | |
setup: | |
name: Setup Project Info | |
runs-on: ubuntu-latest | |
outputs: | |
DIST_SUFFIX: ${{ steps.get-suffix.outputs.DIST_SUFFIX }} | |
steps: | |
- name: 🧐 Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: 📙 Get Package Suffix | |
id: get-suffix | |
run: | | |
# 此处通过 jq 从 package.json 获取版本,否则在 depth | |
# 为 1 时通过 git tag 所读取的版本不准确 | |
sudo apt-get install jq | |
VERSION=$(jq -r '.version' ./package.json) | |
COMMIT_COUNT=$(git rev-list --count HEAD) | |
BUILD_DATE=$(date "+%y%m%d") | |
HEAD_SHA=$(git rev-parse --short HEAD) | |
echo "DIST_SUFFIX=v${VERSION}-${COMMIT_COUNT}-${BUILD_DATE}-${HEAD_SHA}" >> $GITHUB_OUTPUT | |
build: | |
name: Build Production Page | |
needs: setup | |
env: | |
DIST_NAME: dist-${{ needs.setup.outputs.DIST_SUFFIX }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🧐 Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '1' | |
- name: 🛠️ Setup environment | |
id: setup | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: ⚙️ Build production pages | |
id: build | |
run: | | |
pnpm install | |
pnpm add @vue/cli | |
pnpm build | |
- name: 🌐 Upload the build | |
id: upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.DIST_NAME }} | |
path: dist |