Repository navigation
227 lines (199 loc) · 7.74 KB
/
Copy pathbuild.yml
File metadata and controls
227 lines (199 loc) · 7.74 KB
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
name: Build
# Versions come from git tags (MinVer), like the other Exceptionless builds:
# - A v* tag (v0.9.0-beta.1, v1.0.0) builds that version and publishes it to Maven Central.
# - Other pushes build a pre-release version, such as 0.9.0-alpha.0.12 on main or
# 0.9.0-alpha.my-branch.0.12 on a branch, and publish it to GitHub Packages.
# Pre-release labels must be alpha, beta or rc: Maven orders unknown labels such as "preview"
# after the release (1.0.0-preview.1 > 1.0.0).
# - Pull requests build and test only.
#
# Required secrets for releases: CENTRAL_USERNAME and CENTRAL_PASSWORD (a Central Portal user
# token), GPG_PRIVATE_KEY and GPG_PASSPHRASE.
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Never cancel a tag build; it may be publishing a release.
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
defaults:
run:
shell: bash
env:
MAVEN_ARGS: --batch-mode --no-transfer-progress
jobs:
version:
name: Version
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up .NET for MinVer
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: 10.0.x
- name: Compute version
id: version
run: |
# Pre-release versions from branches other than main, maintenance branches (1.x, 1.2),
# tags and pull requests carry the branch name.
branch="${GITHUB_REF##*/}"
if [[ "$GITHUB_REF" != refs/heads/* || "$branch" == main || "$branch" =~ ^[0-9]+\.(x|[0-9]+)$ ]]; then
branch=""
fi
branch="$(tr -c 'A-Za-z0-9-' '-' <<< "$branch" | sed -E 's/-+$//')"
suffix="${branch:+$branch.}"
dotnet tool install --global minver-cli --version 8.0.0
version="$(minver --tag-prefix v --default-pre-release-identifiers "alpha.${suffix}0" --minimum-major-minor 0.9)"
# After a pre-release tag (v1.1.0-beta.1) MinVer appends only the height; add the branch.
if [[ -n "$branch" && "$version" != *"$branch"* ]]; then
version="$(sed -E "s/\.([0-9]+)$/.${suffix}\1/" <<< "$version")"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "### Version: $version" >> "$GITHUB_STEP_SUMMARY"
echo "Version: $version (ref: $GITHUB_REF, event: $GITHUB_EVENT_NAME)"
build:
name: JDK ${{ matrix.java }} on ${{ matrix.os }}
needs: version
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
java: [17, 21, 25]
include:
- os: windows-latest
java: 21
- os: macos-latest
java: 21
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven
- name: Build and test
run: ./mvnw verify -Drevision="$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-reports-${{ matrix.os }}-jdk${{ matrix.java }}
path: '**/target/surefire-reports/'
spring-boot-4:
name: Spring Boot 4 compatibility
needs: version
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: 21
cache: maven
- name: Test the starter against Spring Boot 4
run: ./mvnw -pl exceptionless-spring-boot-starter -am verify -Pspring-boot-4 -Drevision="$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
e2e:
name: End-to-end (real Exceptionless server)
needs: version
runs-on: ubuntu-latest
timeout-minutes: 45
# Every push (so every published build) and pull requests labeled e2e.
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'e2e')
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: 21
cache: maven
- name: Run end-to-end tests
run: ./mvnw -pl exceptionless-e2e-tests -am verify -De2e=true -Drevision="$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
publish-ci:
name: Publish CI packages
needs: [version, build, spring-boot-4, e2e]
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: 21
cache: maven
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
- name: Publish to GitHub Packages
# A CI package is a convenience; failing to publish one doesn't fail the build.
continue-on-error: true
run: >-
./mvnw deploy -DskipTests -Drevision="$VERSION"
-DaltDeploymentRepository="github::https://maven.pkg.github.com/$GITHUB_REPOSITORY"
env:
VERSION: ${{ needs.version.outputs.version }}
GITHUB_TOKEN: ${{ github.token }}
release:
name: Publish to Maven Central
needs: [version, build, spring-boot-4, e2e]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Check the version matches the tag
run: |
if [[ "$VERSION" != "${GITHUB_REF_NAME#v}" ]]; then
echo "::error::Tag $GITHUB_REF_NAME is not a version tag (computed version: $VERSION)."
exit 1
fi
env:
VERSION: ${{ needs.version.outputs.version }}
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: 21
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Publish to Maven Central
run: ./mvnw deploy -Prelease -DskipTests -Drevision="$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}