Skip to content

Commit acc7b5d

Browse files
committed
feat: add release
Signed-off-by: grapebaba <281165273@qq.com>
1 parent 0970aa6 commit acc7b5d

File tree

4 files changed

+149
-35
lines changed

4 files changed

+149
-35
lines changed
File renamed without changes.

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish package to the Maven Central Repository and GitHub Packages
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
packages: write
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- name: Set up JDK 8
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 8
19+
distribution: 'temurin'
20+
- name: Setup Gradle
21+
uses: gradle/gradle-build-action@v2
22+
23+
- name: Execute Gradle build
24+
run: ./gradlew build
25+
26+
- name: Publish package
27+
run: ./gradlew publish
28+
env:
29+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
30+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![sui4j CI](https://github.com/GrapeBaBa/sui4j/actions/workflows/gradle.yml/badge.svg?branch=main)](https://github.com/GrapeBaBa/sui4j/actions/workflows/gradle.yml)
1+
[![sui4j CI](https://github.com/GrapeBaBa/sui4j/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/GrapeBaBa/sui4j/actions/workflows/gradle.yml)
22
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
33
![Coverage](.github/badges/jacoco.svg)
44
![Branches](.github/badges/branches.svg)
@@ -24,7 +24,7 @@ $ ./gradlew build
2424

2525
## Javadoc
2626

27-
For the latest javadocs for the `main` branch, run `./gradlew docs` and open
27+
For the latest javadocs for the `main` branch, run `./gradlew javadoc` and open
2828
the [javadoc](build/docs/javadoc/index.html) in your browser.
2929

3030
## Testing
@@ -71,103 +71,103 @@ final String BASE_URL="http://localhost:9000";
7171
final JsonHandler jsonHandler=new GsonJsonHandler();
7272

7373
final JsonRpcClientProvider jsonRpcClientProvider=
74-
new OkHttpJsonRpcClientProvider(BASE_URL,jsonHandler);
74+
new OkHttpJsonRpcClientProvider(BASE_URL,jsonHandler);
7575
final SuiClient client=new SuiClientImpl(jsonRpcClientProvider);
7676
```
7777

7878
### sui_getCommitteeInfo
7979

8080
```java
81-
CompletableFuture<CommitteeInfoResponse> res=client.getCommitteeInfo(1L);
81+
CompletableFuture<CommitteeInfoResponse> res=client.getCommitteeInfo(1L);
8282
```
8383

8484
### sui_getEvents
8585

8686
```java
87-
TransactionEventQuery query=new TransactionEventQuery();
88-
query.setTransaction("ov1tDrhdOqRW2uFweTbSSTaQbBbnjHWmrsh675lwb0Q=");
89-
CompletableFuture<PaginatedEvents> res=client.getEvents(query,null,1,false);
87+
TransactionEventQuery query=new TransactionEventQuery();
88+
query.setTransaction("ov1tDrhdOqRW2uFweTbSSTaQbBbnjHWmrsh675lwb0Q=");
89+
CompletableFuture<PaginatedEvents> res=client.getEvents(query,null,1,false);
9090
```
9191

9292
### sui_getMoveFunctionArgTypes
9393

9494
```java
95-
CompletableFuture<List<MoveFunctionArgType>>res=
96-
client.getMoveFunctionArgTypes("0x0000000000000000000000000000000000000002","bag","add");
95+
CompletableFuture<List<MoveFunctionArgType>>res=
96+
client.getMoveFunctionArgTypes("0x0000000000000000000000000000000000000002","bag","add");
9797
```
9898

9999
### sui_getNormalizedMoveFunction
100100

101101
```java
102-
CompletableFuture<MoveNormalizedFunction> res=
103-
client.getNormalizedMoveFunction(
104-
"0x0000000000000000000000000000000000000002","bag","add");
102+
CompletableFuture<MoveNormalizedFunction> res=
103+
client.getNormalizedMoveFunction(
104+
"0x0000000000000000000000000000000000000002","bag","add");
105105
```
106106

107107
### sui_getNormalizedMoveModule
108108

109109
```java
110-
CompletableFuture<MoveNormalizedModule> res=
111-
client.getNormalizedMoveModule("0x0000000000000000000000000000000000000002","bag");
110+
CompletableFuture<MoveNormalizedModule> res=
111+
client.getNormalizedMoveModule("0x0000000000000000000000000000000000000002","bag");
112112
```
113113

114114
### sui_getNormalizedMoveModulesByPackage
115115

116116
```java
117-
CompletableFuture<Map<String, MoveNormalizedModule>>res=
118-
client.getNormalizedMoveModulesByPackage("0x0000000000000000000000000000000000000002");
117+
CompletableFuture<Map<String, MoveNormalizedModule>>res=
118+
client.getNormalizedMoveModulesByPackage("0x0000000000000000000000000000000000000002");
119119
```
120120

121121
### sui_getNormalizedMoveStruct
122122

123123
```java
124-
CompletableFuture<MoveNormalizedStruct> res=
125-
client.getNormalizedMoveStruct("0x0000000000000000000000000000000000000002","bag","Bag");
124+
CompletableFuture<MoveNormalizedStruct> res=
125+
client.getNormalizedMoveStruct("0x0000000000000000000000000000000000000002","bag","Bag");
126126
```
127127

128128
### sui_getObject
129129

130130
```java
131-
CompletableFuture<GetObjectResponse> res=
132-
client.getObject("0x342950ba2451c2f27ed128e591c2b4551e5177c2");
131+
CompletableFuture<GetObjectResponse> res=
132+
client.getObject("0x342950ba2451c2f27ed128e591c2b4551e5177c2");
133133
```
134134

135135
### sui_getObjectsOwnedByAddress
136136

137137
```java
138-
CompletableFuture<List<SuiObjectInfo>>res=
139-
client.getObjectsOwnedByAddress("0xea79464d86786b7a7a63e3f13f798f29f5e65947");
138+
CompletableFuture<List<SuiObjectInfo>>res=
139+
client.getObjectsOwnedByAddress("0xea79464d86786b7a7a63e3f13f798f29f5e65947");
140140
```
141141

142142
### sui_getObjectsOwnedByObject
143143

144144
```java
145-
CompletableFuture<List<SuiObjectInfo>>res=
146-
client.getObjectsOwnedByObject("0xde2952390ab3d0cfbb0a0602532480ed5ec99cf3");
145+
CompletableFuture<List<SuiObjectInfo>>res=
146+
client.getObjectsOwnedByObject("0xde2952390ab3d0cfbb0a0602532480ed5ec99cf3");
147147
```
148148

149149
### sui_getRawObject
150150

151151
```java
152-
CompletableFuture<GetObjectResponse> res=
153-
client.getRawObject("0x342950ba2451c2f27ed128e591c2b4551e5177c2");
152+
CompletableFuture<GetObjectResponse> res=
153+
client.getRawObject("0x342950ba2451c2f27ed128e591c2b4551e5177c2");
154154
```
155155

156156
### sui_getTotalTransactionNumber
157157

158158
```java
159-
CompletableFuture<Long> res=client.getTotalTransactionNumber();
159+
CompletableFuture<Long> res=client.getTotalTransactionNumber();
160160
```
161161

162162
### sui_getTransaction
163163

164164
```java
165-
CompletableFuture<TransactionResponse> res=
166-
client.getTransaction("3Dda4/74LXf6GmOxMxp3qdbW/WdQ6/8EHobZ1LvSyYk=");
165+
CompletableFuture<TransactionResponse> res=
166+
client.getTransaction("3Dda4/74LXf6GmOxMxp3qdbW/WdQ6/8EHobZ1LvSyYk=");
167167
```
168168

169169
### sui_getTransactionsInRange
170170

171171
```java
172-
CompletableFuture<List<String>>res=client.getTransactionsInRange(0L,100L);
173-
```
172+
CompletableFuture<List<String>>res=client.getTransactionsInRange(0L,100L);
173+
```

build.gradle

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
plugins {
2-
id 'java'
2+
id 'java-library'
33
id "checkstyle"
44
id "jacoco"
55
id "com.diffplug.spotless" version "6.11.0"
66
id 'org.unbroken-dome.test-sets' version '4.0.0'
7+
id 'maven-publish'
8+
id 'signing'
79
}
810

911

@@ -125,9 +127,9 @@ spotless {
125127
}
126128
}
127129

128-
task docs(type: Javadoc) {
129-
source = sourceSets.main.allJava
130-
}
130+
//task docs(type: Javadoc) {
131+
// source = sourceSets.main.allJava
132+
//}
131133

132134
testSets {
133135
integrationTest
@@ -152,3 +154,84 @@ tasks.withType(Test).configureEach {
152154
]
153155
} as CommandLineArgumentProvider)
154156
}
157+
158+
java {
159+
withJavadocJar()
160+
withSourcesJar()
161+
}
162+
163+
publishing {
164+
publications {
165+
mavenJava(MavenPublication) {
166+
// artifactId = rootProject.name
167+
from components.java
168+
// versionMapping {
169+
// usage('java-api') {
170+
// fromResolutionOf('runtimeClasspath')
171+
// }
172+
// usage('java-runtime') {
173+
// fromResolutionResult()
174+
// }
175+
// }
176+
pom {
177+
name = rootProject.name
178+
description = 'A java SDK for @MystenLabs/sui blockchain.'
179+
url = 'https://github.com/GrapeBaBa/sui4j'
180+
// properties = [
181+
// myProp: "value",
182+
// "prop.with.dots": "anotherValue"
183+
// ]
184+
licenses {
185+
license {
186+
name = 'The Apache License, Version 2.0'
187+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
188+
}
189+
}
190+
developers {
191+
developer {
192+
id = 'grapebaba'
193+
name = 'Kai Chen'
194+
email = '281165273grape@gmail.com'
195+
}
196+
}
197+
scm {
198+
connection = 'scm:git:git://github.com/GrapeBaBa/' + rootProject.name + '.git'
199+
developerConnection = 'scm:git:ssh://github.com/GrapeBaBa/' + rootProject.name + '.git'
200+
url = 'https://github.com/GrapeBaBa/' + rootProject.name
201+
}
202+
}
203+
}
204+
}
205+
repositories {
206+
maven {
207+
name = "OSSRH"
208+
// change URLs to point to your repos, e.g. http://my.org/repo
209+
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
210+
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
211+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
212+
credentials {
213+
username = System.getenv("MAVEN_USERNAME")
214+
password = System.getenv("MAVEN_PASSWORD")
215+
}
216+
}
217+
maven {
218+
name = "GitHubPackages"
219+
url = "https://maven.pkg.github.com/GrapeBaBa/" + rootProject.name
220+
credentials {
221+
username = System.getenv("GITHUB_ACTOR")
222+
password = System.getenv("GITHUB_TOKEN")
223+
}
224+
}
225+
}
226+
}
227+
228+
signing {
229+
sign publishing.publications.mavenJava
230+
}
231+
232+
233+
javadoc {
234+
if (JavaVersion.current().isJava9Compatible()) {
235+
options.addBooleanOption('html5', true)
236+
}
237+
}

0 commit comments

Comments
 (0)