-
Notifications
You must be signed in to change notification settings - Fork 30
121 lines (98 loc) · 4.33 KB
/
javadoc.yaml
File metadata and controls
121 lines (98 loc) · 4.33 KB
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
name: JavaDoc to Documentation Portal
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch/Commit/Tag for JavaDoc'
required: true
default: 'main'
env:
JAVA_VERSION: 17
DOCS_REPO: SAP/cloud-sdk
PROJECTS: '!:rfc,!:dwc-cf,!:datamodel-metadata-generator,!:odata-generator,!:odata-generator-maven-plugin,!:odata-generator-utility,!:odata-v4-generator,!:odata-v4-generator-maven-plugin,!:s4hana-connectivity,!:soap,!:testutil,!:s4hana-core'
jobs:
build:
name: 'JavaDoc to Documentation Portal'
runs-on: ubuntu-latest
steps:
- name: 'Prepare git'
run: |
git config --global user.email "cloudsdk@sap.com"
git config --global user.name "SAP Cloud SDK Bot"
- name: 'Checkout Repository'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 'Switch branch'
run: git checkout "${{ github.event.inputs.branch || 'main' }}"
- name: 'Set up JDK 17'
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: 'Determine Versions'
id: determine-version
run: |
echo "MAJOR_VERSION=$(jq -r '.version' latest.json | cut -d '.' -f 1)" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION=$(jq -r '.version' latest.json)" >> $GITHUB_OUTPUT
- name: 'Install project (skip tests)'
run: mvn install -DskipTests --quiet
- name: 'Process sources'
run: mvn process-sources -Drelease --fail-at-end --projects "${PROJECTS}" --quiet
- name: 'Copy delombok sources'
run: find . -type d -path "*/target/delombok" -exec sh -c 'cp -r "$1"/* "$(dirname $(dirname "$1"))/src/main/java/"' _ {} \;
- name: 'Generate aggregated Javadoc'
run: mvn clean javadoc:aggregate -Drelease -Djava.failOnWarning=false --projects "${PROJECTS}" --quiet
- name: 'Create GitHub App Token'
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.SAP_CLOUD_SDK_BOT_CLIENT_ID }}
private-key: ${{ secrets.SAP_CLOUD_SDK_BOT_PRIVATE_KEY }}
owner: SAP
repositories: cloud-sdk
permission-contents: write
permission-pull-requests: write
- name: 'Checkout Docs Repository'
uses: actions/checkout@v6
with:
repository: ${{ env.DOCS_REPO }}
path: .cloud-sdk-docs
token: ${{ steps.app-token.outputs.token }}
- name: 'Replace JavaDoc'
id: replace-javadoc
run: |
TARGET_DIR=./.cloud-sdk-docs/static/java-api/v${{ steps.determine-version.outputs.MAJOR_VERSION }}
ls -lA target
rm -rf $TARGET_DIR
mkdir -p $TARGET_DIR
mv target/reports/apidocs/* $TARGET_DIR
cd ./.cloud-sdk-docs
git add -A .
CHANGED_FILES="$(git status -s)"
if [[ -z "$CHANGED_FILES" ]]; then
echo "[DEBUG] No changes to API docs detected, skipping Pull Request creation."
echo "CREATE_PR=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "CREATE_PR=true" >> $GITHUB_OUTPUT
BRANCH_NAME=java/release-docs-${{ steps.determine-version.outputs.CURRENT_VERSION }}
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
git switch --create $BRANCH_NAME
git commit -m "chore: Update JavaDocs for release ${{ steps.determine-version.outputs.CURRENT_VERSION }}"
COMMIT_SHA=$(git log -1 --pretty=format:"%H")
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT
git push origin $BRANCH_NAME
- name: 'Create JavaDoc PR'
id: create-javadoc-pr
if: ${{ steps.replace-javadoc.outputs.CREATE_PR == 'true' }}
working-directory: ./.cloud-sdk-docs
run: |
PR_TITLE="Java: Update JavaDocs for release ${{ needs.bump-version.outputs.release-version }}"
PR_BODY="Replace the contents of v${{ steps.determine-version.outputs.MAJOR_VERSION }} API docs with the latest release of the SDK."
PR_URL=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --repo "${{ env.DOCS_REPO }}")
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
echo "PR: $PR_URL" >> $GITHUB_STEP_SUMMARY
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}