-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (62 loc) · 1.92 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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