-
Notifications
You must be signed in to change notification settings - Fork 62
154 lines (152 loc) · 7.03 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
name: build
on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*.**
paths-ignore:
- "docs/**"
merge_group:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "docs/**"
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- run: |
cp gradle.properties.example gradle.properties
- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/setup-node@v4
with:
node-version: "18"
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Setup neo4j
run: |
docker run -d --env NEO4J_AUTH=neo4j/password -p7474:7474 -p7687:7687 neo4j || true
- name: Determine Version
run: |
# determine version from tag
export VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
if [[ $VERSION != v* ]]
then
export VERSION=""
echo "Building version-less (main or feature branch)"
else
# make version more Java-friendly by dropping the 'v'
export VERSION=${VERSION:1:${#VERSION}}
echo "Building as ${VERSION}"
fi
# store version in GitHub environment file
echo "version=$VERSION" >> $GITHUB_ENV
- name: Install JEP
run: |
pip3 install jep==$(grep "black.ninia:jep" gradle/libs.versions.toml | grep -o -E "[0-9]\d*(\.[0-9]\d*)*")
if [ -d "/opt/hostedtoolcache/Python" ]; then
find /opt/hostedtoolcache/Python/ -name libjep.so -exec sudo cp '{}' /usr/lib/ \;
fi
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build ${{ env.version }}
run: |
./gradlew --parallel -Pversion=$VERSION spotlessCheck -x spotlessApply build -x distZip -x distTar koverXmlReport koverHtmlReport performanceTest integrationTest
id: build
env:
VERSION: ${{ env.version }}
- name: Prepare report.xml for Codecov
run: |
# this is needed because codecov incorrectly reports lines that have no coverage information (good or bad) as a miss
# See https://github.com/codecov/feedback/issues/564 and https://github.com/Kotlin/kotlinx-kover/issues/699.
# Actually these lines should just not exist in the coverage XML file, since they are only structural elements, such
# as brackets.
cat cpg-all/build/reports/kover/report.xml | grep -v 'mi="0" ci="0" mb="0" cb="0"' > cpg-all/build/reports/kover/report-codecov.xml
rm cpg-all/build/reports/kover/report.xml
- name: Upload Code Coverage
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./cpg-all/build/reports/kover/report-codecov.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Prepare test and coverage reports
if: ${{ always() }}
run: |
zip -r reports.zip **/build/reports/**/** || true
- name: Archive test and coverage reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: reports
path: reports.zip
- name: Publish to Maven Central
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
run: |
export ORG_GRADLE_PROJECT_signingKey=`echo ${{ secrets.GPG_PRIVATE_KEY }} | base64 -d`
./gradlew --no-daemon -Dorg.gradle.internal.publish.checksums.insecure=true --parallel -Pversion=$VERSION -PenableJavaFrontend=true -PenableCXXFrontend=true -PenableGoFrontend=true -PenablePythonFrontend=true -PenableLLVMFrontend=true -PenableTypeScriptFrontend=true -PenableRubyFrontend=true publishToSonatype closeSonatypeStagingRepository
env:
VERSION: ${{ env.version }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
- name: Download old dokka versions (version)
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
run: |
# make sure the previousDocs folder exists
mkdir -p previousDocs && cd previousDocs
# retrieve the previous documentation folders for each published version (this also includes "main")
wget -O - https://github.com/Fraunhofer-AISEC/cpg/archive/gh-pages.tar.gz | tar -xz --strip=2 cpg-gh-pages/dokka || echo "No dokka directory present. Will continue as if nothing happened"
- name: Download old dokka versions (main)
if: github.ref == 'refs/heads/main'
run: |
# make sure the previousDocs folder exists
mkdir -p previousDocs && cd previousDocs
# retrieve the previous documentation folders for each published version (this also includes "main")
wget -O - https://github.com/Fraunhofer-AISEC/cpg/archive/gh-pages.tar.gz | tar -xz --strip=2 cpg-gh-pages/dokka || echo "No dokka directory present. Will continue as if nothing happened"
# in order to avoid duplicate mains, remove the "main" version from the previous versions
rm -rf main
- name: Build JavaDoc
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha') || github.ref == 'refs/heads/main'
run: |
./gradlew --no-daemon -Pversion=$VERSION dokkaHtmlMultiModule
env:
VERSION: ${{ env.version }}
- name: Publish JavaDoc (version)
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/dokkaCustomMultiModuleOutput/${{ env.version }}
target-folder: dokka/${{ env.version }}
- name: Publish JavaDoc (version as main)
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/dokkaCustomMultiModuleOutput/${{ env.version }}
target-folder: dokka/main
- name: Publish JavaDoc (main)
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/dokkaCustomMultiModuleOutput/main
target-folder: dokka/main
- name: Create Release
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
id: create_release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.version }}
draft: false
prerelease: false