Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit c88db09

Browse files
authored
Merge pull request #878 from linwumingshi/ci/grpc-and-websocket
ci: 👷 Add WebSocket and gRPC Documentation Generation
2 parents 73c89ac + 310ec35 commit c88db09

1 file changed

Lines changed: 106 additions & 123 deletions

File tree

.github/workflows/build-and-run-example-project.yml

Lines changed: 106 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ on:
77
paths:
88
- 'src/**' # Trigger workflow only if files in src directory change
99
- 'pom.xml' # Trigger workflow only if pom.xml file changes
10+
11+
env:
12+
smart-doc-version: ${{ github.run_id }} # Use the current GitHub workflow run ID as a temporary version number
13+
1014
jobs:
1115
build:
12-
if: ${{ github.event.pull_request.changed_files > 0 }} # Run only if there are file changes
16+
if: ${{ github.event.pull_request.changed_files > 0 }} # Run this job only if there are file changes
1317
runs-on: ubuntu-latest
1418

1519
steps:
16-
- name: Checkout Plugin Repository
20+
- name: Checkout Repository
1721
uses: actions/checkout@v4
1822

19-
- name: Set up JDK 11
23+
- name: Set up JDK 17
2024
uses: actions/setup-java@v4
2125
with:
22-
java-version: '11'
26+
java-version: '17'
2327
distribution: 'temurin'
2428

29+
- name: Update Version in pom.xml
30+
run: mvn versions:set -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
31+
2532
- name: Build and Install Plugin
2633
run: mvn install
2734

@@ -33,83 +40,18 @@ jobs:
3340
path: ~/.m2/repository/com/ly/smart-doc
3441
if-no-files-found: error
3542

36-
gen-rest-api-doc:
43+
maven-plugin-build:
3744
needs: build
3845
runs-on: ubuntu-latest
3946
concurrency:
40-
group: generate-rest-api-doc-${{ github.event.pull_request.number }}
47+
group: maven-plugin-build-${{ github.event.pull_request.number }}
4148
cancel-in-progress: true
4249

4350
steps:
44-
- name: Checkout Example Project
45-
uses: actions/checkout@v4
46-
with:
47-
repository: smart-doc-group/smart-doc-example-cn
48-
token: ${{ secrets.GITHUB_TOKEN }}
49-
50-
- name: Set up JDK 17
51-
uses: actions/setup-java@v4
52-
with:
53-
java-version: '17'
54-
distribution: 'temurin'
55-
56-
- name: Build and Install Example Project
57-
run: mvn -DskipTests=true install
58-
59-
- name: Download Artifact
60-
uses: actions/download-artifact@v4
61-
with:
62-
name: smart-doc-maven-jar
63-
path: ./artifacts
64-
65-
- name: Move Files to Local Maven Repository
66-
run: |
67-
mkdir -p ~/.m2/repository/com/ly/smart-doc
68-
echo "Overwriting target directory with new artifacts:"
69-
rsync -av --delete ./artifacts/ ~/.m2/repository/com/ly/smart-doc/
70-
echo "Listing files in target directory:"
71-
ls -lh ~/.m2/repository/com/ly/smart-doc
72-
73-
74-
- name: Generate AsciiDoc Documentation
75-
run: mvn -DskipTests=true smart-doc:adoc
76-
77-
- name: Generate HTML Documentation
78-
run: mvn -DskipTests=true smart-doc:html
79-
80-
- name: Generate JMeter Documentation
81-
run: mvn -DskipTests=true smart-doc:jmeter
82-
83-
- name: Generate Markdown Documentation
84-
run: mvn -DskipTests=true smart-doc:markdown
85-
86-
- name: Generate OpenAPI Documentation
87-
run: mvn -DskipTests=true smart-doc:openapi
88-
89-
- name: Generate Postman Documentation
90-
run: mvn -DskipTests=true smart-doc:postman
91-
92-
- name: Generate Word Documentation
93-
run: mvn -DskipTests=true smart-doc:word
94-
95-
- name: Upload REST API Documentation
96-
uses: actions/upload-artifact@v4
97-
with:
98-
name: rest-api-docs
99-
path: /home/runner/work/smart-doc/smart-doc/target/doc/
100-
101-
gen-dubbo-api-doc:
102-
needs: build
103-
runs-on: ubuntu-latest
104-
concurrency:
105-
group: generate-dubbo-api-doc-${{ github.event.pull_request.number }}
106-
cancel-in-progress: true
107-
108-
steps:
109-
- name: Checkout Example Project
51+
- name: Checkout Maven Plugin Repository
11052
uses: actions/checkout@v4
11153
with:
112-
repository: smart-doc-group/smart-doc-example-cn
54+
repository: TongchengOpenSource/smart-doc-maven-plugin
11355
token: ${{ secrets.GITHUB_TOKEN }}
11456

11557
- name: Set up JDK 17
@@ -118,9 +60,6 @@ jobs:
11860
java-version: '17'
11961
distribution: 'temurin'
12062

121-
- name: Build and Install Example Project
122-
run: mvn -DskipTests=true install
123-
12463
- name: Download Artifact
12564
uses: actions/download-artifact@v4
12665
with:
@@ -135,27 +74,29 @@ jobs:
13574
echo "Listing files in target directory:"
13675
ls -lh ~/.m2/repository/com/ly/smart-doc
13776
77+
- name: Update Version in pom.xml
78+
run: |
79+
mvn versions:set-property -Dproperty="smart-doc.version" -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
13880
139-
- name: Generate RPC AsciiDoc Documentation
140-
run: mvn -DskipTests=true smart-doc:rpc-adoc
141-
142-
- name: Generate RPC HTML Documentation
143-
run: mvn -DskipTests=true smart-doc:rpc-html
144-
145-
- name: Generate RPC Markdown Documentation
146-
run: mvn -DskipTests=true smart-doc:rpc-markdown
81+
- name: Build and Install
82+
run: mvn -DskipTests=true install
14783

148-
- name: Upload RPC API Documentation
84+
- name: Upload Plugin Artifact
85+
id: upload-artifact
14986
uses: actions/upload-artifact@v4
15087
with:
151-
name: dubbo-api-docs
152-
path: /home/runner/work/smart-doc/smart-doc/target/doc/
88+
name: smart-doc-maven-plugin-jar
89+
path: ~/.m2/repository/com/ly/smart-doc
90+
if-no-files-found: error
15391

154-
gen-javadoc-api-doc:
155-
needs: build
92+
generate-api-docs:
93+
needs: maven-plugin-build
15694
runs-on: ubuntu-latest
95+
strategy:
96+
matrix:
97+
doc_type: [ rest, dubbo, javadoc, websocket ]
15798
concurrency:
158-
group: generate-javadoc-api-doc-${{ github.event.pull_request.number }}
99+
group: generate-${{ matrix.doc_type }}-api-doc-${{ github.event.pull_request.number }}
159100
cancel-in-progress: true
160101

161102
steps:
@@ -171,13 +112,10 @@ jobs:
171112
java-version: '17'
172113
distribution: 'temurin'
173114

174-
- name: Build and Install Example Project
175-
run: mvn -DskipTests=true install
176-
177115
- name: Download Artifact
178116
uses: actions/download-artifact@v4
179117
with:
180-
name: smart-doc-maven-jar
118+
name: smart-doc-maven-plugin-jar
181119
path: ./artifacts
182120

183121
- name: Move Files to Local Maven Repository
@@ -188,27 +126,57 @@ jobs:
188126
echo "Listing files in target directory:"
189127
ls -lh ~/.m2/repository/com/ly/smart-doc
190128
129+
- name: Update Smart-Doc Version in pom.xml
130+
run: |
131+
mvn versions:set-property -Dproperty="smart-doc.version" -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
191132
192-
- name: Generate Javadoc AsciiDoc Documentation
193-
run: mvn -DskipTests=true smart-doc:javadoc-adoc
194-
195-
- name: Generate Javadoc HTML Documentation
196-
run: mvn -DskipTests=true smart-doc:javadoc-html
197-
198-
- name: Generate Javadoc Markdown Documentation
199-
run: mvn -DskipTests=true smart-doc:javadoc-markdown
133+
- name: Build and Install Example Project
134+
run: mvn -DskipTests=true install
200135

201-
- name: Upload Javadoc API Documentation
136+
- name: Generate ${{ matrix.doc_type }} API Documentation
137+
run: |
138+
case ${{ matrix.doc_type }} in
139+
rest)
140+
mvn -DskipTests=true smart-doc:adoc
141+
mvn -DskipTests=true smart-doc:html
142+
mvn -DskipTests=true smart-doc:jmeter
143+
mvn -DskipTests=true smart-doc:markdown
144+
mvn -DskipTests=true smart-doc:openapi
145+
mvn -DskipTests=true smart-doc:postman
146+
mvn -DskipTests=true smart-doc:word
147+
;;
148+
dubbo)
149+
mvn -DskipTests=true smart-doc:rpc-adoc
150+
mvn -DskipTests=true smart-doc:rpc-html
151+
mvn -DskipTests=true smart-doc:rpc-markdown
152+
;;
153+
javadoc)
154+
mvn -DskipTests=true smart-doc:javadoc-adoc
155+
mvn -DskipTests=true smart-doc:javadoc-html
156+
mvn -DskipTests=true smart-doc:javadoc-markdown
157+
;;
158+
websocket)
159+
mvn -DskipTests=true smart-doc:websocket-adoc
160+
mvn -DskipTests=true smart-doc:websocket-html
161+
mvn -DskipTests=true smart-doc:websocket-markdown
162+
;;
163+
esac
164+
165+
- name: Upload ${{ matrix.doc_type }} API Documentation
202166
uses: actions/upload-artifact@v4
203167
with:
204-
name: javadoc-api-docs
205-
path: /home/runner/work/smart-doc/smart-doc/target/doc/
168+
name: ${{ matrix.doc_type }}-api-doc
169+
path: ${{ github.workspace }}/target/doc/
170+
if-no-files-found: error
206171

207-
gen-websocket-api-doc:
208-
needs: build
209-
runs-on: ubuntu-latest
172+
generate-grpc-api-doc:
173+
needs: maven-plugin-build
174+
runs-on: ${{ matrix.os }}
175+
strategy:
176+
matrix:
177+
os: [ubuntu-latest, macos-latest, windows-latest]
210178
concurrency:
211-
group: generate-websocket-api-doc-${{ github.event.pull_request.number }}
179+
group: generate-grpc-api-doc-${{ matrix.os }}-${{ github.event.pull_request.number }}
212180
cancel-in-progress: true
213181

214182
steps:
@@ -224,30 +192,45 @@ jobs:
224192
java-version: '17'
225193
distribution: 'temurin'
226194

227-
- name: Build and Install Example Project
228-
run: mvn -DskipTests=true install
229-
230195
- name: Download Artifact
231196
uses: actions/download-artifact@v4
232197
with:
233-
name: smart-doc-maven-jar
198+
name: smart-doc-maven-plugin-jar
234199
path: ./artifacts
235200

236201
- name: Move Files to Local Maven Repository
237202
run: |
238-
mkdir -p ~/.m2/repository/com/ly/smart-doc
239-
echo "Overwriting target directory with new artifacts:"
240-
rsync -av --delete ./artifacts/ ~/.m2/repository/com/ly/smart-doc/
241-
echo "Listing files in target directory:"
242-
ls -lh ~/.m2/repository/com/ly/smart-doc
203+
if [[ "${{ matrix.os }}" == "ubuntu-latest" || "${{ matrix.os }}" == "macos-latest" ]]; then
204+
TARGET_DIR=~/.m2/repository/com/ly/smart-doc/
205+
mkdir -p "$TARGET_DIR" || echo "Directory already exists"
206+
rsync -av --delete ./artifacts/ "$TARGET_DIR"
207+
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
208+
TARGET_DIR="$USERPROFILE\\.m2\\repository\\com\\ly\\smart-doc\\"
209+
mkdir -p "$TARGET_DIR" || echo "Directory already exists"
210+
cp -r ./artifacts/* "$TARGET_DIR"
211+
fi
212+
shell: bash
213+
214+
215+
- name: Update Smart-Doc Version in pom.xml
216+
run: |
217+
mvn versions:set-property -Dproperty="smart-doc.version" -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
218+
219+
- name: Build and Install Example Project
220+
run: mvn -DskipTests=true install
243221

222+
- name: Generate gRPC AsciiDoc Documentation
223+
run: mvn -DskipTests=true smart-doc:grpc-adoc
244224

245-
- name: Generate WebSocket Markdown Documentation
246-
run: mvn -DskipTests=true smart-doc:websocket-markdown
225+
- name: Generate gRPC HTML Documentation
226+
run: mvn -DskipTests=true smart-doc:grpc-html
247227

228+
- name: Generate gRPC Markdown Documentation
229+
run: mvn -DskipTests=true smart-doc:grpc-markdown
248230

249-
- name: Upload WebSocket API Documentation
231+
- name: Upload gRPC API Documentation
250232
uses: actions/upload-artifact@v4
251233
with:
252-
name: websocket-api-doc
253-
path: /home/runner/work/smart-doc/smart-doc/target/doc/
234+
name: gRPC-api-doc-${{ runner.os }}
235+
path: ${{ github.workspace }}/target/doc/
236+
if-no-files-found: error

0 commit comments

Comments
 (0)