forked from Taskana/TaskanaAdapter
-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (158 loc) · 6.24 KB
/
continuous-integration.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
155
156
157
158
159
160
161
162
163
164
165
166
name: CI TASKANA adapter
on:
workflow_dispatch:
push:
branches-ignore:
- dependabot/**
tags:
- '[0-9]+\.[0-9]+\.[0-9]+/[0-9]+\.[0-9]+\.[0-9]+'
pull_request:
branches:
- master
schedule:
- cron: '0 3 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.repository }}/${{ github.ref }}
cancel-in-progress: true
env:
JAVA_VERSION: 17
CACHE_MAVEN_NAME: ma2aen
CACHE_SONAR_NAME: sonar
ARTIFACTS_JACOCO_REPORTS_NAME: jacoco-reports
ARTIFACTS_JACOCO_REPORTS_PATH: '**/jacoco.exec'
jobs:
compile_and_test:
name: Test
runs-on: ubuntu-20.04
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: ${{ env.JAVA_VERSION }}
- name: Cache maven dependencies
id: cache
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}
- name: Test
run: ./mvnw -B verify
- name: Upload JaCoCo Report
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACTS_JACOCO_REPORTS_NAME }}
path: ${{ env.ARTIFACTS_JACOCO_REPORTS_PATH }}
if-no-files-found: ignore
- name: Remove taskana artifacts from cache
run: rm -rf ~/.m2/repository/pro/taskana
release_artifacts:
runs-on: ubuntu-20.04
name: Release artifacts to OSS Sonatype
if: github.repository == 'Taskana/TaskanaAdapter' && ( startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master' ) && github.head_ref == ''
needs: [ compile_and_test ]
# as documented in the gpg manual (https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html)
# we should execute this command before interacting with gpg (otherwise gpg won't work)
env:
GPG_TTY: $(tty)
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # necessary for push back
# NOTE @v2 uses the token as an auth http header. Set it to
# a Personal Access Token instead of secrets.GITHUB_TOKEN
# so that tag pushes trigger repo push events.
# source: https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/7
token: ${{ secrets.ADMIN_PERSONAL_ACCESS_TOKEN }}
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: ${{ env.JAVA_VERSION }}
- name: Cache maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}
- name: Import GPG Key
run: echo -n "$GPG_KEY" | base64 --decode | gpg --batch --import
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
- name: Change versions to match tag
run: ci/change_version.sh -m .
- name: Release artifacts to OSS Sonatype
run: |
./mvnw -B deploy -P $([[ "$GITHUB_REF" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+/[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "release" || echo "snapshot") \
--settings ci/mvnsettings.xml -DskipTests -Dcheckstyle.skip -Djacoco.skip \
-pl :taskana-adapter-parent,\
:taskana-adapter,:taskana-adapter-camunda-system-connector,:taskana-adapter-taskana-connector,\
:taskana-adapter-camunda-listener,:taskana-adapter-camunda-outbox-rest,\
:taskana-adapter-camunda-outbox-rest-spring-boot-starter
env:
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_USERNAME: 44pdzWD8
MAVEN_PASSWORD: eJZ25rsRdH7ZiePJO52JUy7LyVkNIgXxXEBmnTNH3aOM
- name: Update version to next snapshot and push back
run: |
ci/change_version.sh -i -m .
ci/commitPoms.sh
env:
GH_EMAIL: ${{ secrets.GH_EMAIL }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
- name: Remove taskana artifacts from cache
run: rm -rf ~/.m2/repository/pro/taskana
- name: Cancel workflow
if: failure()
uses: andymckay/[email protected]
upload_to_sonar:
runs-on: ubuntu-20.04
name: Upload SonarQube analysis to sonarcloud
# no pull request and not on release
if: github.head_ref == '' && !startsWith(github.ref, 'refs/tags')
needs: [ compile_and_test ]
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: ${{ env.JAVA_VERSION }}
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-${{ env.CACHE_SONAR_NAME }}
restore-keys: ${{ runner.os }}-${{ env.CACHE_SONAR_NAME }}
- name: Cache maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}
- name: Download JaCoCo reports
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACTS_JACOCO_REPORTS_NAME }}
- name: Install taskana adapter
run: ./mvnw -B install -DskipTests -Dcheckstyle.skip -Dmaven.javadoc.skip
- name: Upload SonarQube analysis
run: ./mvnw -B sonar:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
- name: Remove taskana artifacts from cache
run: rm -rf ~/.m2/repository/pro/taskana
- name: Cancel workflow
if: failure()
uses: andymckay/[email protected]