-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (65 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
69
70
71
72
73
name: Build Production Page
on:
push:
branches: [wu_main]
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 从 packagr.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: '0'
- name: 🛠️ Setup Node.js Env
id: setup-node
uses: actions/setup-node@main
with:
node-version: latest
- name: 🔧 Setup Yarn
id: setup-yarn
run: |
npm install yarn -g
yarn set version berry
- name: 🚧 Setup dependencies
id: setup-deps
run: |
yarn add @vue/cli
yarn install
- name: ⚙️ Build production pages
id: build
run: |
yarn build
- name: 🌐 Upload the build
id: upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.DIST_NAME }}
path: dist
retention-days: 60