-
Notifications
You must be signed in to change notification settings - Fork 62
225 lines (194 loc) · 7.19 KB
/
release.yml
File metadata and controls
225 lines (194 loc) · 7.19 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
name: Release to Maven Central
on:
# Manual trigger
workflow_dispatch:
inputs:
release_version:
description: "Version to release (if empty, derive from project version)"
required: false
# Automatic trigger on pushing a version tag (e.g., "v1.2.3")
push:
tags:
- "v*"
jobs:
# Corresponds to tests in tests.yml
build-with-docker:
name: Build ${{ matrix.dockcross-only }} (Dockcross)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
java-distribution: [adopt]
java-version: [11]
dockcross-only:
[
"android-arm",
"android-arm64",
"linux-arm64",
"linux-armv5",
"linux-armv7",
"linux-s390x",
"linux-ppc64le",
"linux-x64",
"linux-x86",
"windows-static-x64",
"windows-static-x86",
]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-java@v5
with:
distribution: "${{ matrix.java-distribution }}"
java-version: "${{ matrix.java-version }}"
- uses: gradle/actions/setup-gradle@v5
with:
gradle-version: wrapper
- uses: actions/cache@v5
id: gradle-cache
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Tests
run: ./gradlew clean test -Ph3SystemPrune=true "-Ph3DockcrossOnly=${{ matrix.dockcross-only }}"
env:
OCI_EXE: docker
- uses: actions/upload-artifact@v6
name: Upload artifacts
with:
name: docker-built-shared-objects-${{ matrix.dockcross-only }}
path: |
src/main/resources/*/*.so
src/main/resources/*/*.dll
if-no-files-found: error
# Corresponsd to tests-no-docker in tests.yml
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
java-distribution: [adopt]
java-version: [11]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-java@v5
with:
distribution: "${{ matrix.java-distribution }}"
java-version: "${{ matrix.java-version }}"
- uses: gradle/actions/setup-gradle@v5
with:
gradle-version: wrapper
- uses: actions/cache@v5
id: gradle-cache
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Tests
run: ./gradlew clean test
- uses: actions/upload-artifact@v6
name: Upload Mac OS Artifacts
with:
name: macos-built-shared-objects
path: src/main/resources/*/*.dylib
if-no-files-found: error
release:
runs-on: ubuntu-22.04
permissions:
contents: write # allow pushing commits/tags
needs:
- build-with-docker
- build
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: "21"
- name: Determine release version
id: vars
run: |
# Derive the release version (drop "-SNAPSHOT") from Gradle project or input
VERSION_INPUT="${{ github.event.inputs.release_version || '' }}"
if [ -n "$VERSION_INPUT" ]; then
RELEASE_VERSION="$VERSION_INPUT"
else
RELEASE_VERSION=$(grep -E 'version=' gradle.properties | sed -E 's/version=//')
fi
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Remove -SNAPSHOT suffix (prepare release version)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
sed -i -E "s/${RELEASE_VERSION}-SNAPSHOT/$RELEASE_VERSION/" gradle.properties || true
git config user.name "github-actions"
git config user.email "[email protected]"
git commit -am "chore: release $RELEASE_VERSION [skip ci]"
- name: Create Git tag for release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
git tag -a "v${RELEASE_VERSION}" -m "Release $RELEASE_VERSION"
git push origin HEAD:master --follow-tags
- name: Download Docker binaries
uses: actions/download-artifact@v7
with:
pattern: docker-built-shared-objects-*
merge-multiple: true
path: src/main/resources/
- name: Download Mac binaries
uses: actions/download-artifact@v7
with:
name: macos-built-shared-objects
path: src/main/resources/
- name: Download and test
run: |
./gradlew clean test assemble -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true
- name: List files in jars
run: |
ls -lh build/libs
for f in build/libs/*.jar; do
echo "File: $f"
unzip -l "$f"
done
- name: Publish to Sonatype OSSRH (Maven Central)
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
# OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
run: ./gradlew publishAndReleaseToMavenCentral -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true
- name: Create GitHub Release (with changelog notes)
# This uses an action to create a release on GitHub
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.RELEASE_VERSION }}"
name: "${{ env.RELEASE_VERSION }}"
body_path: CHANGELOG.md # assumes changelog contains latest release notes at top
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This doesn't work because we don't permit pushes directly to main.
# - name: Bump to next snapshot version
# if: ${{ github.event_name != 'workflow_dispatch' }}
# run: |
# # Bump minor version (for example) and append -SNAPSHOT for continued development
# NEXT_VERSION=$(echo $RELEASE_VERSION | awk -F. -v OFS="." '{$NF += 1; print $0}') # increment last segment
# NEXT_VERSION="$NEXT_VERSION-SNAPSHOT"
# sed -i -E "s/$RELEASE_VERSION/$NEXT_VERSION/" gradle.properties || true
# git config user.name "github-actions"
# git config user.email "[email protected]"
# git commit -am "chore: start next development cycle $NEXT_VERSION [skip ci]"
# git push origin HEAD:master