-
Notifications
You must be signed in to change notification settings - Fork 38
195 lines (176 loc) · 7.4 KB
/
java-publish.yml
File metadata and controls
195 lines (176 loc) · 7.4 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
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Java Publish
on:
release:
types:
- released
pull_request:
paths:
- .github/workflows/java-publish.yml
workflow_dispatch:
inputs:
mode:
description: 'Release mode'
required: true
type: choice
default: dry_run
options:
- dry_run
- release
ref:
description: 'The branch, tag or SHA to checkout'
required: false
type: string
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: java
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# When triggered by a release, use the release tag
# When triggered manually with a ref, use the provided ref
# Otherwise (PR or manual without ref), use the default branch
ref: ${{ github.event.release.tag_name || inputs.ref || '' }}
- name: Set up Java sdk
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
server-id: ossrh
server-username: SONATYPE_USER
server-password: SONATYPE_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set github
run: |
git config --global user.name "Lance Github Runner"
git config --global user.email "dev+gha@lance.org"
- name: Dry run
if: |
github.event_name == 'pull_request' ||
inputs.mode == 'dry_run'
run: |
./mvnw --batch-mode -DskipTests -Dgpg.skip=true verify -P deploy-to-ossrh
- name: Java Publish
if: |
(github.event_name == 'release' && github.event.action == 'released') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'release')
run: |
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
export GPG_TTY=$(tty)
./mvnw --batch-mode -DskipTests -DpushChanges=false -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy -P deploy-to-ossrh
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
- name: Get published version
if: |
(github.event_name == 'release' && github.event.action == 'released') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'release')
id: get_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Published version: $VERSION"
- name: Wait for Maven Central availability
if: |
(github.event_name == 'release' && github.event.action == 'released') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'release')
run: |
VERSION="${{ steps.get_version.outputs.version }}"
GROUP_ID="org.lance"
# List of some artifacts to check
ARTIFACTS=(
"lance-namespace-apache-client"
"lance-namespace-async-client"
"lance-namespace-core"
"lance-namespace-core-async"
)
echo "Waiting for version $VERSION to be available in Maven Central..."
echo "This typically takes 10-30 minutes after publishing to OSSRH."
# Maximum wait time: 60 minutes
MAX_WAIT=3600
INTERVAL=60
ELAPSED=0
while [ $ELAPSED -lt $MAX_WAIT ]; do
ALL_AVAILABLE=true
for ARTIFACT_ID in "${ARTIFACTS[@]}"; do
URL="https://repo1.maven.org/maven2/org/lance/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.pom"
if curl --head --silent --fail "$URL" > /dev/null 2>&1; then
echo "✓ ${ARTIFACT_ID} is available"
else
echo "✗ ${ARTIFACT_ID} is not yet available"
ALL_AVAILABLE=false
fi
done
if [ "$ALL_AVAILABLE" = true ]; then
echo ""
echo "🎉 All artifacts are now available in Maven Central!"
echo ""
echo "Users can now add the following dependencies to their projects:"
echo ""
echo "Maven (sync interface):"
echo "<dependency>"
echo " <groupId>org.lance</groupId>"
echo " <artifactId>lance-namespace-core</artifactId>"
echo " <version>${VERSION}</version>"
echo "</dependency>"
echo ""
echo "Maven (async interface - Java 11+):"
echo "<dependency>"
echo " <groupId>org.lance</groupId>"
echo " <artifactId>lance-namespace-core-async</artifactId>"
echo " <version>${VERSION}</version>"
echo "</dependency>"
echo ""
echo "Maven (sync client):"
echo "<dependency>"
echo " <groupId>org.lance</groupId>"
echo " <artifactId>lance-namespace-apache-client</artifactId>"
echo " <version>${VERSION}</version>"
echo "</dependency>"
echo ""
echo "Maven (async client - Java 11+):"
echo "<dependency>"
echo " <groupId>org.lance</groupId>"
echo " <artifactId>lance-namespace-async-client</artifactId>"
echo " <version>${VERSION}</version>"
echo "</dependency>"
echo ""
echo "Gradle (sync):"
echo "implementation 'org.lance:lance-namespace-core:${VERSION}'"
echo "implementation 'org.lance:lance-namespace-apache-client:${VERSION}'"
echo ""
echo "Gradle (async - Java 11+):"
echo "implementation 'org.lance:lance-namespace-core-async:${VERSION}'"
echo "implementation 'org.lance:lance-namespace-async-client:${VERSION}'"
exit 0
fi
ELAPSED=$((ELAPSED + INTERVAL))
if [ $ELAPSED -lt $MAX_WAIT ]; then
echo ""
echo "Artifacts not yet available. Waiting ${INTERVAL} seconds... (${ELAPSED}s elapsed)"
sleep $INTERVAL
fi
done
echo ""
echo "⚠️ WARNING: Artifacts are not yet available in Maven Central after ${MAX_WAIT} seconds."
echo "This is normal - Maven Central sync can take up to 2 hours."
echo "The artifacts will appear at: https://central.sonatype.com/artifact/org.lance/lance-namespace-apache-client/${VERSION}"
echo ""
echo "You can check the sync status at: https://s01.oss.sonatype.org/"
exit 0