-
-
Notifications
You must be signed in to change notification settings - Fork 147
111 lines (95 loc) · 3.45 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
name: build
on:
push:
pull_request:
types: [opened, synchronize, reopened]
release:
types: [published]
jobs:
build:
name: Build with JDK ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
java: [8, 11, 17, 20]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: ${{ matrix.java }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Assemble the Project
run: ./gradlew assemble
- name: Run Tests
run: ./gradlew check
- name: Generate JaCoCo Report
run: ./gradlew jacocoTestReport
- name: Generate JaCoCo Badges
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: >
ktorm-core/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-global/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-jackson/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-support-mysql/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-support-oracle/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-support-postgresql/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-support-sqlite/build/reports/jacoco/test/jacocoTestReport.csv
ktorm-support-sqlserver/build/reports/jacoco/test/jacocoTestReport.csv
- name: Upload Jacoco Badges
if: matrix.java == '8'
continue-on-error: true
run: |
REPO_DIR=~/.ktorm/temp/repo/ktorm-docs
git clone --depth=1 --branch=master https://github.com/kotlin-orm/ktorm-docs.git "$REPO_DIR"
cp .github/badges/jacoco.svg "$REPO_DIR/source/images"
cp .github/badges/branches.svg "$REPO_DIR/source/images"
cd "$REPO_DIR"
if [[ `git status --porcelain` ]]; then
git config user.name 'vince'
git config user.email '[email protected]'
git add .
git commit -m "[github actions] update jacoco badges"
git push "https://[email protected]/kotlin-orm/ktorm-docs.git" master
fi
env:
GIT_PUSH_TOKEN: ${{secrets.GIT_PUSH_TOKEN}}
publish:
name: Publish Artifacts
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 8
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Assemble the Project
run: ./gradlew assemble
- name: Publish Artifacts
run: |
if [[ $(cat "ktorm.version") =~ "SNAPSHOT" ]] ; then
./gradlew publishDistPublicationToSnapshotRepository
else
if [[ $GITHUB_EVENT_NAME == "release" ]] ; then
./gradlew publishDistPublicationToCentralRepository
else
echo "Skip release publication because this is not a release event"
fi
fi
env:
OSSRH_USER: ${{secrets.OSSRH_USER}}
OSSRH_PASSWORD: ${{secrets.OSSRH_PASSWORD}}
GPG_KEY_ID: ${{secrets.GPG_KEY_ID}}
GPG_PASSWORD: ${{secrets.GPG_PASSWORD}}
GPG_SECRET_KEY: ${{secrets.GPG_SECRET_KEY}}