-
Notifications
You must be signed in to change notification settings - Fork 3
273 lines (271 loc) · 9.77 KB
/
release.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: Release
on:
push:
branches:
- main
paths-ignore:
- '.github/actions/**'
- '**.md'
jobs:
# FETCH CURRENT PLUGIN VERSION
fetch-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
release: ${{ steps.get_version.outputs.release }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Plugin Version
id: get_version
run: |
VERSION=$(grep "version" gradle.properties | cut -d'=' -f2)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
else
echo "release=false" >> $GITHUB_OUTPUT
fi
# Compiles all Gosu test projects using Java 11 beforehand.
# By leveraging Gradle cache, this enabled us to run integration tests of Gosu projects against Sonarqube Server
# with versions running on Java 17.
# This is necessary UNTIL Gosu supports Java 17.
prep-integration-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java:
- 11
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: 'gradle'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: integration-tests-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
integration-tests-${{ runner.os }}-gradle
- name: Compile Test Projects
run: |
cd src/testIntegration/resources
./compile-projects.sh
integration-tests:
needs: [prep-integration-tests]
runs-on: ubuntu-latest
strategy:
matrix:
include:
# previous LTS version
- SONAR_SERVER_VERSION: 8.9.10
SONAR_WS_VERSION: 8.9.9.56886
SONAR_PLUGIN_API_VERSION: 6.7.7
SONAR_JAVA_VERSION: 7.11.0.29148
SONAR_SERVER_JAVA_VERSION: 11
- SONAR_SERVER_VERSION: 9.7.0
SONAR_WS_VERSION: 8.9.9.56886
SONAR_PLUGIN_API_VERSION: 6.7.7
SONAR_JAVA_VERSION: 7.13.0.29990
SONAR_SERVER_JAVA_VERSION: 11
# current LTS version
- SONAR_SERVER_VERSION: 9.9.0
SONAR_WS_VERSION: 8.9.9.56886
SONAR_PLUGIN_API_VERSION: 6.7.7
SONAR_JAVA_VERSION: 7.13.0.29990
SONAR_SERVER_JAVA_VERSION: 17
- SONAR_SERVER_VERSION: 10.0.0
SONAR_WS_VERSION: 8.9.9.56886
SONAR_PLUGIN_API_VERSION: 6.7.7
SONAR_JAVA_VERSION: 7.13.0.29990
SONAR_SERVER_JAVA_VERSION: 17
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.SONAR_SERVER_JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.SONAR_SERVER_JAVA_VERSION }}
distribution: temurin
cache: 'gradle'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: integration-tests-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
integration-tests-${{ runner.os }}-gradle
- name: Run Integration Tests
run: |
./gradlew testIntegration --build-cache --no-daemon \
-PsonarqubeServerVersion=${{ matrix.SONAR_SERVER_VERSION }} \
-PsonarqubeWsVersion=${{ matrix.SONAR_WS_VERSION }} \
-PsonarPluginApiVersion=${{ matrix.SONAR_PLUGIN_API_VERSION }} \
-PsonarJavaVersion=${{ matrix.SONAR_JAVA_VERSION }}
snapshot:
needs: [fetch-version, integration-tests]
if: needs.fetch-version.outputs.release == 'false'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java:
- 11
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: 'gradle'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: |
./gradlew clean build --build-cache --no-daemon
- name: Sonar
run: |
./gradlew sonar --no-daemon \
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }} \
-Dsonar.host.url=${{ env.SONAR_HOST_URL }} \
-Dsonar.pullrequest.provider=github \
-Dsonar.pullrequest.github.repository=${{ github.repository }} \
-Dsonar.branch.name=${GITHUB_REF##*/}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Archive artifact
if: success() && matrix.java == '11'
uses: actions/upload-artifact@v3
with:
name: snapshot
path: build/libs/*.jar
# RELEASE THE PLUGIN
release:
needs: [fetch-version, integration-tests]
if: needs.fetch-version.outputs.release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
cache: 'gradle'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up Git
run: |
git config --global user.name "${{ env.RELEASE_USER_NAME }}"
git config --global user.email "${{ env.RELEASE_USER_EMAIL }}"
git remote set-url origin https://x-access-token:${RELEASE_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_USER_EMAIL: ${{ secrets.RELEASE_USER_EMAIL }}
RELEASE_USER_NAME: ${{ secrets.RELEASE_USER_NAME }}
- name: Generate Next Plugin Version
run: |
MAJOR=$(echo $RELEASE_VERSION | cut -d. -f1)
MINOR=$(echo $RELEASE_VERSION | cut -d. -f2)
PATCH=$(echo $RELEASE_VERSION | cut -d. -f3)
PATCH=$((PATCH + 1))
NEXT_PLUGIN_VERSION="$MAJOR.$MINOR.$PATCH-SNAPSHOT"
echo "Next Version will be: ${NEXT_PLUGIN_VERSION}"
echo "NEXT_PLUGIN_VERSION=${NEXT_PLUGIN_VERSION}" >> $GITHUB_ENV
env:
RELEASE_VERSION: ${{ needs.fetch-version.outputs.version }}
- name: Release
if: success()
run: |
./gradlew clean release \
-Prelease.useAutomaticVersion=true \
-Prelease.releaseVersion=${{ needs.fetch-version.outputs.version }} \
-Prelease.newVersion=${{ env.NEXT_PLUGIN_VERSION }}
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Sonar
run: |
./gradlew sonar --no-daemon \
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }} \
-Dsonar.host.url=${{ env.SONAR_HOST_URL }} \
-Dsonar.pullrequest.provider=github \
-Dsonar.pullrequest.github.repository=${{ github.repository }} \
-Dsonar.projectVersion=${{ needs.fetch-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Archive artifact
uses: actions/upload-artifact@v3
with:
name: release
path: build/libs/*.jar
- name: Fetch ChangeLog
if: success()
run: |
./gradlew getChangelog -q --no-header --no-summary > ${{ github.workspace }}-CHANGELOG.txt
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.fetch-version.outputs.version }}
tag_name: v${{ needs.fetch-version.outputs.version }}
body_path: ${{ github.workspace }}-CHANGELOG.txt
draft: true
files: |
build/libs/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}