-
Notifications
You must be signed in to change notification settings - Fork 11
135 lines (119 loc) · 3.79 KB
/
Copy pathbuild.yml
File metadata and controls
135 lines (119 loc) · 3.79 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
# Build and Test
#
# Description:
# Builds the project and runs unit tests for every supported Java version.
#
# Triggers:
# - pull_request: when a PR targets main
# - push: when code is pushed to main
# - milestone: when milestone metadata changes
#
# Notes:
# Builds against Java 17, 21, and 25.
name: Build
run-name: Build - ${{ github.event_name }}
on:
workflow_dispatch:
milestone:
types: [created, edited, closed, deleted]
pull_request:
branches:
- main
paths:
- '.github/workflows/build.yml'
- 'sdk/**'
- 'sdk-testing/**'
- 'sdk-integration-tests/**'
- 'examples/**'
- 'pom.xml'
push:
branches:
- main
paths:
- '.github/workflows/build.yml'
- 'sdk/**'
- 'sdk-testing/**'
- 'sdk-integration-tests/**'
- 'examples/**'
- 'pom.xml'
permissions:
contents: read
issues: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java:
- 17
- 21
- 25
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'milestone' && github.event.repository.default_branch || github.ref }}
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v5
with:
distribution: corretto
java-version: ${{ matrix.java }}
cache: maven
- name: Build and test
run: mvn -B install --file pom.xml
- name: Generate JaCoCo Badge
if: ${{ matrix.java == 17 }}
uses: cicirello/jacoco-badge-generator@72266185b7ee48a6fd74eaf0238395cc8b14fef8 # v2
with:
jacoco-csv-file: coverage-report/target/site/jacoco-aggregate/jacoco.csv
badges-directory: coverage-report/target/site/jacoco-aggregate
- name: Generate javadoc site
if: ${{ matrix.java == 17 }}
run: mvn -B -pl sdk -am javadoc:javadoc
- name: Generate milestone badge
if: ${{ matrix.java == 17 }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TITLE=$(gh api repos/${{ github.repository }}/milestones \
--jq '[.[] | select(.state == "open" and .due_on != null)] | sort_by(.due_on) | .[0].title // empty')
if [ -z "$TITLE" ]; then
URL="https://img.shields.io/badge/Next%20Milestone-No%20milestone-lightgrey"
else
ENCODED=$(echo -n "$TITLE" | jq -sRr @uri | sed 's/-/--/g')
URL="https://img.shields.io/badge/Next%20Milestone-${ENCODED}-blue"
fi
mkdir -p milestone
curl -sfL "$URL" -o milestone/badge.svg
echo "Badge generated for: ${TITLE:-No milestone}"
- name: Configure GitHub Pages
if: ${{ matrix.java == 17 }}
uses: actions/configure-pages@v6
- name: Prepare GitHub Pages artifact
if: ${{ matrix.java == 17 }}
run: |
mkdir -p github-pages/coverage github-pages/javadoc github-pages/milestone
cp -R coverage-report/target/site/jacoco-aggregate/. github-pages/coverage
cp -R sdk/target/reports/apidocs/. github-pages/javadoc
cp -R milestone/. github-pages/milestone
touch github-pages/.nojekyll
- name: Upload GitHub Pages artifact
if: ${{ matrix.java == 17 }}
uses: actions/upload-pages-artifact@v5
with:
path: github-pages
deploy-pages:
if: ${{ github.event_name == 'milestone' || github.ref == 'refs/heads/main' }}
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy GitHub Pages
id: deployment
uses: actions/deploy-pages@v5