-
Notifications
You must be signed in to change notification settings - Fork 2k
142 lines (122 loc) · 3.93 KB
/
generate-api-docs.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Generate API docs JSON
on:
push:
tags:
- '**'
branches-ignore:
- '**'
pull_request:
workflow_dispatch:
inputs:
target_tag:
description: 'The ref (branch or tag) to build API docs'
type: string
default: 'v3.8.4'
required: true
jobs:
build-api-doc:
runs-on: ubuntu-latest
name: "Generate API docs JSON"
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Get ref
id: step-id-get-ref
run: |
if [ "${{ github.event_name }}" = 'workflow_dispatch' ]; then
echo "Get ref from workflow_dispatch"
echo "ENGINE_REF=${{ github.event.inputs.target_tag }}" >> $GITHUB_OUTPUT
else
echo "Get ref from push"
echo "ENGINE_REF=${{ github.ref }}" >> $GITHUB_OUTPUT
fi
- name: Show ref
run: |
echo "ref: ${{ steps.step-id-get-ref.outputs.ENGINE_REF }}"
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.step-id-get-ref.outputs.ENGINE_REF }}
- name: Checkout the tool
uses: actions/checkout@v4
with:
repository: cocos/creator-api-doc
path: creator-api-doc
ref: main
- name: Install the tool
run: |
cd creator-api-doc
npm i
# apply the url patch for [email protected]
npm run apply-patch
npm run build
- name: Try to switch to Node v14
if: github.event_name == 'workflow_dispatch'
run: |
cd creator-api-doc/scripts
eval $(./is-smaller-version.sh ${{ steps.step-id-get-ref.outputs.ENGINE_REF }} "3.8.0")
if [[ "$IS_LESS" == "1" ]]; then
echo "Version less than 3.8.0"
export NVM_DIR="$HOME/mynvm"
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
pushd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
popd
chmod +x "$NVM_DIR/nvm.sh"
. "$NVM_DIR/nvm.sh" --no-use
nvm install 14
nvm use 14
nvm alias default 14
echo "SETUP_NODE_NVM_NVM: $NVM_DIR/nvm.sh"
echo "SETUP_NODE_NVM_NODE: $(which node)"
echo "SETUP_NODE_NVM_NPM: $(which npm)"
else
echo "No need to switch to Node v14"
fi
- name: Patch taobao npm mirror
if: github.event_name == 'workflow_dispatch'
run: |
ENGINE_ROOT=$(pwd)
cd creator-api-doc/scripts
eval $(./is-smaller-version.sh ${{ steps.step-id-get-ref.outputs.ENGINE_REF }} "3.8.4")
if [[ "$IS_LESS" == "1" ]]; then
echo "Version less than 3.8.4"
node ./replace-taobao.js $ENGINE_ROOT
sed -i 's/nlark/npmmirror/g' $ENGINE_ROOT/package-lock.json
else
echo "No need to patch taobao npm mirror"
fi
- name: Download external libraries
run: |
EXT_VERSION=`grep checkout native/external-config.json | awk -F'"' '{print $4}'`
echo "EXT_VERSION: ${EXT_VERSION}"
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
- name: Install Cocos Engine
run: |
export NVM_DIR="$HOME/mynvm"
if [ -d "$NVM_DIR" ]; then
echo "Found NVM_DIR"
. "$NVM_DIR/nvm.sh" --no-use
nvm use 14
nvm alias default 14
fi
echo "NODE: $(which node)"
echo "NPM: $(which npm)"
npm i
- name: Generate
run: |
which node
node --version
pwd
ls -l
ENGINE_ROOT=$(pwd)
echo "ENGINE_ROOT: ${ENGINE_ROOT}"
cd creator-api-doc
node ./lib/cli.js -p $ENGINE_ROOT -o $ENGINE_ROOT/Cocos-Creator-API.json
ls -l ..
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Cocos-Creator-API
path: Cocos-Creator-API.json