-
Notifications
You must be signed in to change notification settings - Fork 1
220 lines (190 loc) · 6.92 KB
/
build.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
name: JMH CI
env:
GITHUB_DEPLOY: 'true'
on:
push:
branches:
- main
tags:
- '*'
paths-ignore:
- LICENSE
- README.md
- 'docs/**'
- '.github/config/labels.yml'
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
repository_dispatch:
types: [ app-release ]
defaults:
run:
shell: bash
jobs:
build:
if: startsWith(github.event.head_commit.message, 'skip ci') != true
name: Run JMH Benchmark.
timeout-minutes: 15
continue-on-error: false
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
jdk: [ ea ]
include:
- os: ubuntu-latest
cmd: ./mvnw
- os: macos-latest
cmd: ./mvnw
- os: windows-latest
cmd: ./mvnw.cmd
permissions:
contents: read
packages: write
outputs:
sha-version: ${{ steps.sha-version.outputs.version }}
steps:
- name: Check out the source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download OpenJDK ${{ matrix.jdk }} build from jdk.java.net
id: download-jdk
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ matrix.jdk }}
version: latest
install: false
- name: Download OpenJDK (fallback)
if: ${{ false }}
run: |
download_url="https://download.java.net/java/early_access/jdkea/latest/GPL/openjdk-ea-latest_linux-x64_bin.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- name: Set up OpenJDK ${{ matrix.jdk }} with dep cache
id: setup-java
uses: actions/setup-java@v4
if: always() && steps.download-jdk.outcome == 'success'
with:
distribution: jdkfile
java-version: ${{ steps.download-jdk.outputs.version }}
jdkFile: ${{ steps.download-jdk.outputs.archive }}
check-latest: true
cache: 'maven'
# jdkFile: ${{ runner.temp }}/java_package.tar.gz
# architecture: x64
# settings-path: ${{ github.workspace }} # OR $GITHUB_WORKSPACE
- name: Print Env
shell: bash
run: |
echo "steps.download-jdk.outputs.file = ${{ steps.download-jdk.outputs.file }}"
echo "steps.download-jdk.outputs.version = ${{ steps.download-jdk.outputs.version }}"
echo "steps.setup-java.outputs.path = ${{ steps.setup-java.outputs.path }}"
echo "env.JDK_FILE = ${{ env.JDK_FILE }}"
echo "env.JDK_VERSION = ${{ env.JDK_VERSION }}"
echo "GITHUB_ENV = $GITHUB_ENV"
echo "GITHUB_PATH = $GITHUB_PATH"
echo "JAVA_HOME = $JAVA_HOME"
echo "JAVA_HOME_11 = $JAVA_HOME_11_X64"
# echo "JAVA_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
# echo "$JAVA_HOME_11_X64/bin" >> $GITHUB_PATH
- name: Create Version Number
id: sha-version
run: |
SHA_VERSION=$(echo $GITHUB_SHA | cut -c1-7)
echo "version=$SHA_VERSION" >>"$GITHUB_OUTPUT"
- name: Maven Build
run: ./mvnw verify
- name: Deploy to GitHub Packages (Linux)
id: maven-deploy
if: env.GITHUB_DEPLOY == 'true' && runner.os == 'Linux' && github.event_name == 'push'
run: |
./mvnw --settings .mvn/settings.xml clean deploy
env:
GITHUB_USER: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run JMH Benchmark
if: success()
run: |
java --enable-preview -jar target/benchmarks.jar -rf json -rff jmh-result-${{ runner.os }}.json
# mkdir staging && cp {$result_file,target/benchmarks.jar} staging
- name: Uploading JMH ${{ matrix.os }} benchmark results
uses: actions/upload-artifact@v4
with:
name: jmh-result-${{ runner.os }}.json
path: |
*.json
if-no-files-found: error
- name: Uploading JMH ${{ matrix.os }} benchmark jar
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: benchmarks-${{ runner.os }}.jar
path: |
target/benchmarks.jar
if-no-files-found: error
release:
name: Release new version.
needs: [ build ]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Print Git SHA version
shell: bash
run: |
echo "The SHA version from build job: ${{ needs.build.outputs.sha-version }}"
- name: Get the version
id: get-version
run: |
echo "GITHUB_REF = $GITHUB_REF"
echo "version=${GITHUB_REF#refs/*/}" >>"$GITHUB_OUTPUT"
echo "branch=${GITHUB_REF#refs/heads/}" >>"$GITHUB_OUTPUT"
echo "tag=${GITHUB_REF#refs/tags/}" >>"$GITHUB_OUTPUT"
# echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Check out the source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/config/configuration.json"
commitMode: true
ignorePreReleases: ${{ !contains(github.ref, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download all the build artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Commit and push JMH Results
if: success()
run: |
# git diff
echo "Copying JMH result JSON files to docs..."
find release-artifacts -name "*.json" -type f -exec cp -prv "{}" docs \;
git config user.name github-actions
git config user.email [email protected]
git add docs
git commit -m "doc: Updated JMH Results" || exit 0
# You are not currently on a branch (detached HEAD)
git push origin HEAD:${{ github.event.repository.default_branch }}
# Alternatives are listed here - https://github.com/actions/create-release
- name: Github Release
uses: softprops/action-gh-release@v1
with:
# name: Release ${{ steps.get-version.outputs.tag }}
# tag_name: ${{ github.ref }}
# release_name: ${{ github.ref }}
body: ${{ steps.github_release.outputs.changelog }}
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-b') || contains(github.ref, '-a') }}
files: |
${{ github.workspace }}/release-artifacts/**
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}