-
Notifications
You must be signed in to change notification settings - Fork 4
133 lines (131 loc) · 4.73 KB
/
ci.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
name: CI
on:
pull_request:
branches: [ main, release/* ]
push:
branches: [ main, release/* ]
release:
types: [ published ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
check-latest: true
distribution: temurin
java-version: ${{ matrix.java }}
- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-maven-artifacts
with:
key: cudami-cache-java-${{ matrix.java }}-${{ github.run_id }}
path: |
~/.m2/repository
**/target
- name: Check Java codestyle
run: mvn com.spotify.fmt:fmt-maven-plugin:check
- name: Set up Node.js
uses: actions/setup-node@v3
with:
check-latest: true
node-version: 12
- name: Check Javascript codestyle
run: npm install && npm run format-check
working-directory: dc-cudami-editor
- name: Build with Maven
run: mvn -B -U clean verify -Pproduction
strategy:
matrix:
java: [17]
coverage:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-maven-artifacts
with:
key: cudami-cache-java-17-${{ github.run_id }}
path: |
~/.m2/repository
**/target
- name: Publish code coverage reports
uses: codecov/codecov-action@v3
publish:
if: (github.event_name == 'push' && (contains(github.ref, 'main') || startsWith(github.ref, 'release/'))) || github.event_name == 'release'
needs: build
outputs:
PROJECT_VERSION: ${{ steps.projectversion.outputs.PROJECT_VERSION }}
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-maven-artifacts
with:
key: cudami-cache-java-17-${{ github.run_id }}
path: |
~/.m2/repository
**/target
- name: Install XML utils
run: sudo apt update && sudo apt install libxml2-utils
- name: Extract project version
run: echo "PROJECT_VERSION=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml)" >> $GITHUB_ENV
- name: Set project version as output variable
id: projectversion
run: echo "PROJECT_VERSION=${{ env.PROJECT_VERSION }}" >> $GITHUB_OUTPUT
# Publish snapshot
- name: Set up JDK 17 for publishing a snapshot
if: github.event_name == 'push' && endswith(env.PROJECT_VERSION, 'SNAPSHOT')
uses: actions/setup-java@v3
with:
check-latest: true
distribution: temurin
java-version: 17
server-id: ossrh-snapshots
server-password: MAVEN_PASSWORD
server-username: MAVEN_USERNAME
- name: Publish snapshot to the Maven Central Repository
if: github.event_name == 'push' && endswith(env.PROJECT_VERSION, 'SNAPSHOT')
run: mvn -B deploy -DskipTests
env:
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
# Publish release
- name: Set up JDK 17 for publishing a release
if: github.event_name == 'release' && !endswith(env.PROJECT_VERSION, 'SNAPSHOT')
uses: actions/setup-java@v3
with:
check-latest: true
distribution: temurin
gpg-passphrase: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
java-version: 17
server-id: ossrh
server-password: MAVEN_PASSWORD
server-username: MAVEN_USERNAME
- name: Publish release to the Maven Central Repository
if: github.event_name == 'release' && !endswith(env.PROJECT_VERSION, 'SNAPSHOT')
run: mvn -B deploy -DskipTests -Pdeploy
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
deploy:
if: github.event_name == 'push' && contains(github.ref, 'main') && endswith(needs.publish.outputs.PROJECT_VERSION, 'SNAPSHOT')
runs-on: ubuntu-latest
needs: publish
steps:
- name: Deploy cudami
run: curl -X POST -F token=${{ secrets.TRIGGER_TOKEN }} -F ref=main -F "variables[DEPLOY_VERSION_TO_ENVIRONMENT]=$(printf '%s > development' ${{ needs.publish.outputs.PROJECT_VERSION }})" ${{ secrets.TRIGGER_URL }}