Skip to content

Commit 327f998

Browse files
committed
add option to override host; change maven publish workflow to trigger when release is published
1 parent dca1308 commit 327f998

5 files changed

Lines changed: 53 additions & 36 deletions

File tree

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
name: Publish to Maven Central
22
on:
33
release:
4-
types: [created]
4+
types: [published]
55
jobs:
66
publish:
77
name: Publish to Maven Central
88
runs-on: ubuntu-latest
9-
9+
1010
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v4
13-
14-
- name: Set up JDK 17
15-
uses: actions/setup-java@v4
16-
with:
17-
java-version: '17'
18-
distribution: 'temurin'
19-
server-id: central
20-
server-username: MAVEN_USERNAME
21-
server-password: MAVEN_PASSWORD
22-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
23-
gpg-passphrase: MAVEN_GPG_PASSPHRASE
24-
25-
- name: Verify GPG setup
26-
run: gpg --list-secret-keys --keyid-format LONG
27-
28-
- name: Publish to Maven Central
29-
run: |
30-
./mvnw deploy -B \
31-
-Prelease \
32-
-DskipTests
33-
env:
34-
# Maven Central credentials via https://central.sonatype.com/account
35-
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
36-
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
37-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v4
16+
with:
17+
java-version: "17"
18+
distribution: "temurin"
19+
server-id: central
20+
server-username: MAVEN_USERNAME
21+
server-password: MAVEN_PASSWORD
22+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
23+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
24+
25+
- name: Verify GPG setup
26+
run: gpg --list-secret-keys --keyid-format LONG
27+
28+
- name: Publish to Maven Central
29+
run: |
30+
./mvnw deploy -B \
31+
-Prelease \
32+
-DskipTests
33+
env:
34+
# Maven Central credentials via https://central.sonatype.com/account
35+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
36+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
37+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>at.allaboutapps.integresql</groupId>
88
<artifactId>integresql-java-client</artifactId>
99
<description>A Java client library for interacting with an IntegreSQL server.</description>
10-
<version>1.0.1</version>
10+
<version>1.0.2</version>
1111
<name>${project.groupId}:${project.artifactId}</name>
1212
<url>https://github.com/allaboutapps/integresql-client-java</url>
1313

@@ -128,6 +128,11 @@
128128

129129
<build>
130130
<plugins>
131+
<plugin>
132+
<groupId>org.apache.maven.plugins</groupId>
133+
<artifactId>maven-compiler-plugin</artifactId>
134+
<version>3.13.0</version>
135+
</plugin>
131136
<plugin>
132137
<groupId>org.apache.maven.plugins</groupId>
133138
<artifactId>maven-source-plugin</artifactId>

src/main/java/at/allaboutapps/integresql/client/IntegresqlJavaClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ public void setupTemplate(String hash, Consumer<String> initializer) throws Exce
337337
config.port = this.config.portOverride.get();
338338
}
339339

340+
if (this.config.hostOverride.isPresent()) {
341+
config.host = this.config.hostOverride.get();
342+
}
343+
340344
String connectionString = config.connectionString();
341345
// Add user/password to connection string for JDBC
342346
String user = Objects.requireNonNull(config.username, "Template username is null");
@@ -412,6 +416,10 @@ public void setupTemplateWithDBClient(String hash, Consumer<Connection> initiali
412416
config.port = this.config.portOverride.get();
413417
}
414418

419+
if (this.config.hostOverride.isPresent()) {
420+
config.host = this.config.hostOverride.get();
421+
}
422+
415423
String connectionString = config.connectionString(); // Base URL: jdbc:postgresql://host:port/database
416424
String user = Objects.requireNonNull(config.username, "Template username is null");
417425
String password = Objects.requireNonNull(config.password, "Template password is null");

src/main/java/at/allaboutapps/integresql/config/IntegresqlClientConfig.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ public class IntegresqlClientConfig {
1010
private final String apiVersion;
1111
public final Boolean debug;
1212
public final Optional<Integer> portOverride;
13+
public final Optional<String> hostOverride;
1314

1415
// Private constructor for builder pattern or factory method
15-
private IntegresqlClientConfig(String baseUrl, String apiVersion, Boolean debug, Optional<Integer> portOverride) {
16+
private IntegresqlClientConfig(String baseUrl, String apiVersion, Boolean debug, Optional<Integer> portOverride,
17+
Optional<String> hostOverride) {
1618
this.baseUrl = baseUrl;
1719
this.apiVersion = apiVersion;
1820
this.debug = debug != null ? debug : false;
1921
this.portOverride = portOverride != null ? portOverride : Optional.empty();
22+
this.hostOverride = hostOverride != null ? hostOverride : Optional.empty();
2023
}
2124

2225
// --- Getters ---
@@ -43,7 +46,7 @@ public static IntegresqlClientConfig defaultConfigFromEnv() {
4346
String envBaseUrl = EnvUtil.getEnv("INTEGRESQL_CLIENT_BASE_URL", "http://integresql:5000/api");
4447
String envApiVersion = EnvUtil.getEnv("INTEGRESQL_CLIENT_API_VERSION", "v1");
4548
Boolean envDebug = EnvUtil.getEnvAsBool("INTEGRESQL_CLIENT_DEBUG", false);
46-
return new IntegresqlClientConfig(envBaseUrl, envApiVersion, envDebug, Optional.empty());
49+
return new IntegresqlClientConfig(envBaseUrl, envApiVersion, envDebug, Optional.empty(), Optional.empty());
4750
}
4851

4952
/**
@@ -55,7 +58,7 @@ public static IntegresqlClientConfig defaultConfigFromEnv() {
5558
* @return A new IntegresqlClientConfig instance.
5659
*/
5760
public static IntegresqlClientConfig customConfig(String baseUrl, String apiVersion, Boolean debug,
58-
Optional<Integer> portOverride) {
61+
Optional<Integer> portOverride, Optional<String> hostOverride) {
5962
if (baseUrl == null || baseUrl.trim().isEmpty()) {
6063
throw new IllegalArgumentException("Base URL cannot be null or empty");
6164
}
@@ -65,6 +68,6 @@ public static IntegresqlClientConfig customConfig(String baseUrl, String apiVers
6568
if (debug == null) {
6669
debug = false; // Default to false if not provided
6770
}
68-
return new IntegresqlClientConfig(baseUrl, apiVersion, debug, portOverride);
71+
return new IntegresqlClientConfig(baseUrl, apiVersion, debug, portOverride, hostOverride);
6972
}
7073
}

src/test/java/at/allaboutapps/integresql/IntegresqlJavaClientIntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ static void setupClient() {
9999
// Construct base URL for IntegreSQL API
100100
String baseUrl = String.format("http://%s:%d/api", host, mappedPortIntegreSQL);
101101

102-
IntegresqlClientConfig config = IntegresqlClientConfig.customConfig(baseUrl, "v1", false, Optional.empty());
102+
IntegresqlClientConfig config = IntegresqlClientConfig.customConfig(baseUrl, "v1", false, Optional.empty(),
103+
Optional.of(postgresContainer.getHost()));
103104
client = new IntegresqlJavaClient(config);
104105
log.info("PostgreSQL Test Container running at jdbc:postgresql://{}:{}/{} (internal alias: {})",
105106
postgresContainer.getHost(), postgresContainer.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT),
@@ -234,7 +235,7 @@ void testGetTestDatabase() throws SQLException {
234235
// config1.host = postgresContainer.getHost(); // Use the host of the PostgreSQL
235236
// container
236237

237-
config1.host = "localhost";
238+
// config1.host = "localhost";
238239
String url1 = config1.connectionString(); // Base URL
239240
log.info("Connecting to DB1: {}", url1);
240241
try (Connection conn1 = DriverManager.getConnection(url1, config1.username, config1.password)) {

0 commit comments

Comments
 (0)