Skip to content

Commit bf4aba7

Browse files
committed
build(cicd): release automation
- Create workflows for releases and snapshots - Bump maven version to 3.9.11 via maven wrapper - Bump various maven plugins - Move unit test to separate profile - Bump httpclient to httpclient5
1 parent 7c86c97 commit bf4aba7

File tree

12 files changed

+575
-381
lines changed

12 files changed

+575
-381
lines changed

.github/workflows/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains the GitHub Actions workflows for the project.
4+
5+
## Workflows
6+
7+
### 1. tests.yml
8+
- **Trigger**: Push to master branch or pull requests to master
9+
- **Purpose**: Run all tests (unit and integration) on multiple Tarantool versions
10+
- **Runs on**: Ubuntu latest
11+
12+
### 2. release.yml
13+
- **Trigger**: Creation of tags matching semantic versioning pattern (e.g., `1.4.0`, `2.0.1`)
14+
- **Purpose**: Automatically release to Maven Central and create GitHub Release
15+
- **Runs on**: Ubuntu latest
16+
- **Requires secrets**:
17+
- `OSSRH_USERNAME` - Sonatype OSSRH username
18+
- `OSSRH_TOKEN` - Sonatype OSSRH password or token
19+
- `MAVEN_GPG_PRIVATE_KEY` - GPG private key for signing artifacts
20+
- `MAVEN_GPG_PASSPHRASE` - Passphrase for the GPG key
21+
- `TARANTOOL_REGISTRY_PASSWORD` - Password for Tarantool private registry
22+
23+
### 3. snapshot.yml
24+
- **Trigger**: Push to master branch (except commits starting with "Release")
25+
- **Purpose**: Automatically deploy snapshot versions to Maven Central
26+
- **Runs on**: Ubuntu latest
27+
- **Requires secrets**:
28+
- `OSSRH_USERNAME` - Sonatype OSSRH username
29+
- `OSSRH_TOKEN` - Sonatype OSSRH password or token
30+
- `TARANTOOL_REGISTRY_PASSWORD` - Password for Tarantool private registry
31+
32+
## Setup Instructions
33+
34+
To enable automatic releases, you need to configure the following secrets in your GitHub repository settings:
35+
36+
1. Go to Settings → Secrets and variables → Actions
37+
2. Add the following secrets:
38+
- `OSSRH_USERNAME` - Your Sonatype OSSRH username
39+
- `OSSRH_TOKEN` - Your Sonatype OSSRH token/password
40+
- `MAVEN_GPG_PRIVATE_KEY` - Your GPG private key (export with `gpg --export-secret-keys --armor KEY_ID`)
41+
- `MAVEN_GPG_PASSPHRASE` - Passphrase for your GPG key
42+
- `TARANTOOL_REGISTRY_PASSWORD` - Password for the Tarantool private registry
43+
44+
## Release Process
45+
46+
### Automatic Release
47+
1. Create and push a new tag with semantic versioning format (e.g., `git tag 1.4.0 && git push origin 1.4.0`)
48+
2. The release workflow will automatically:
49+
- Build and test the project
50+
- Sign the artifacts with GPG
51+
- Deploy to Maven Central
52+
- Create a GitHub Release
53+
54+
### Automatic Snapshot Deployment
55+
1. Push changes to the master branch
56+
2. The snapshot workflow will automatically:
57+
- Build and test the project
58+
- Deploy snapshot version to Maven Central
59+
60+
Note: Commits with messages starting with "Release" are excluded from snapshot deployment to avoid duplicate deployments during the release process.

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v5
14+
15+
- name: Set up JDK 8
16+
uses: actions/setup-java@v5
17+
with:
18+
distribution: 'zulu'
19+
java-version: '8'
20+
server-id: central
21+
server-username: MAVEN_USERNAME
22+
server-password: MAVEN_TOKEN
23+
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_GPG_PRIVATE_KEY }}
24+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
25+
26+
- name: Configure Git user
27+
run: |
28+
git config user.email "actions@github.com"
29+
git config user.name "GitHub Actions"
30+
31+
- name: Publish to Maven Central
32+
run: |
33+
./mvnw -B clean deploy -PsonatypeRelease -DskipTests
34+
env:
35+
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USER }}
36+
MAVEN_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
37+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE }}

.github/workflows/snapshot.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish Snapshot to Maven Central
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+\-dev.[0-9]+'
9+
10+
jobs:
11+
publish-snapshot:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
17+
- name: Set up JDK 8
18+
uses: actions/setup-java@v5
19+
with:
20+
distribution: 'zulu'
21+
java-version: '8'
22+
server-id: central-portal-snapshots
23+
server-username: MAVEN_USERNAME
24+
server-password: MAVEN_TOKEN
25+
26+
- name: Publish Snapshot to Maven Central
27+
run: |
28+
./mvnw -B clean deploy -PsonatypeSnapshot -DskipTests
29+
env:
30+
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USER }}
31+
MAVEN_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}

.github/workflows/tests.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v4
2424

2525
- name: Set up JDK 1.8
26-
uses: actions/setup-java@v4
26+
uses: actions/setup-java@v5
2727
with:
2828
distribution: 'zulu'
2929
java-version: '8'
@@ -32,8 +32,11 @@ jobs:
3232
- name: Docker login to private registry
3333
run: docker login "$TARANTOOL_REGISTRY" -u admin -p "${{ secrets.TARANTOOL_REGISTRY_PASSWORD }}"
3434

35-
- name: Build and run unit tests
36-
run: ./mvnw -B verify -Djacoco.destFile=target/jacoco-cartridge-container.exec --file pom.xml
35+
- name: Build
36+
run: ./mvnw -B clean package --file pom.xml
37+
38+
- name: Run unit tests
39+
run: ./mvnw -B test -P unit -Djacoco.destFile=target/jacoco-cartridge-container.exec --file pom.xml
3740

3841
- name: Run integration tests
3942
env:
@@ -64,7 +67,7 @@ jobs:
6467
- uses: actions/checkout@v4
6568

6669
- name: Set up JDK 1.8
67-
uses: actions/setup-java@v4
70+
uses: actions/setup-java@v5
6871
with:
6972
distribution: 'zulu'
7073
java-version: '8'
@@ -101,7 +104,7 @@ jobs:
101104
- uses: actions/checkout@v4
102105

103106
- name: Set up JDK 1.8
104-
uses: actions/setup-java@v4
107+
uses: actions/setup-java@v5
105108
with:
106109
distribution: 'zulu'
107110
java-version: '8'
Lines changed: 69 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,96 @@
11
/*
2-
* Copyright 2007-present the original author or authors.
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
39
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
711
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
1518
*/
16-
import java.net.*;
17-
import java.io.*;
18-
import java.nio.channels.*;
19-
import java.util.Properties;
20-
21-
public class MavenWrapperDownloader {
2219

23-
private static final String WRAPPER_VERSION = "0.5.6";
24-
/**
25-
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26-
*/
27-
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28-
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
20+
import java.io.IOException;
21+
import java.io.InputStream;
22+
import java.net.Authenticator;
23+
import java.net.PasswordAuthentication;
24+
import java.net.URI;
25+
import java.net.URL;
26+
import java.nio.file.Files;
27+
import java.nio.file.Path;
28+
import java.nio.file.Paths;
29+
import java.nio.file.StandardCopyOption;
30+
import java.util.concurrent.ThreadLocalRandom;
2931

30-
/**
31-
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32-
* use instead of the default one.
33-
*/
34-
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35-
".mvn/wrapper/maven-wrapper.properties";
32+
public final class MavenWrapperDownloader {
33+
private static final String WRAPPER_VERSION = "3.3.4";
3634

37-
/**
38-
* Path where the maven-wrapper.jar will be saved to.
39-
*/
40-
private static final String MAVEN_WRAPPER_JAR_PATH =
41-
".mvn/wrapper/maven-wrapper.jar";
35+
private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE"));
4236

43-
/**
44-
* Name of the property which should be used to override the default download url for the wrapper.
45-
*/
46-
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
37+
public static void main(String[] args) {
38+
log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION);
4739

48-
public static void main(String args[]) {
49-
System.out.println("- Downloader started");
50-
File baseDirectory = new File(args[0]);
51-
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52-
53-
// If the maven-wrapper.properties exists, read it and check if it contains a custom
54-
// wrapperUrl parameter.
55-
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56-
String url = DEFAULT_DOWNLOAD_URL;
57-
if(mavenWrapperPropertyFile.exists()) {
58-
FileInputStream mavenWrapperPropertyFileInputStream = null;
59-
try {
60-
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61-
Properties mavenWrapperProperties = new Properties();
62-
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63-
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64-
} catch (IOException e) {
65-
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66-
} finally {
67-
try {
68-
if(mavenWrapperPropertyFileInputStream != null) {
69-
mavenWrapperPropertyFileInputStream.close();
70-
}
71-
} catch (IOException e) {
72-
// Ignore ...
73-
}
74-
}
40+
if (args.length != 2) {
41+
System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing");
42+
System.exit(1);
7543
}
76-
System.out.println("- Downloading from: " + url);
7744

78-
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79-
if(!outputFile.getParentFile().exists()) {
80-
if(!outputFile.getParentFile().mkdirs()) {
81-
System.out.println(
82-
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83-
}
84-
}
85-
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
8645
try {
87-
downloadFileFromURL(url, outputFile);
88-
System.out.println("Done");
89-
System.exit(0);
90-
} catch (Throwable e) {
91-
System.out.println("- Error downloading");
92-
e.printStackTrace();
46+
log(" - Downloader started");
47+
final URL wrapperUrl = URI.create(args[0]).toURL();
48+
final Path baseDir = Paths.get(".").toAbsolutePath().normalize();
49+
final Path wrapperJarPath = baseDir.resolve(args[1]).normalize();
50+
if (!wrapperJarPath.startsWith(baseDir)) {
51+
throw new IOException("Invalid path: outside of allowed directory");
52+
}
53+
downloadFileFromURL(wrapperUrl, wrapperJarPath);
54+
log("Done");
55+
} catch (IOException e) {
56+
System.err.println("- Error downloading: " + e.getMessage());
57+
if (VERBOSE) {
58+
e.printStackTrace();
59+
}
9360
System.exit(1);
9461
}
9562
}
9663

97-
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
64+
private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath)
65+
throws IOException {
66+
log(" - Downloading to: " + wrapperJarPath);
9867
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99-
String username = System.getenv("MVNW_USERNAME");
100-
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
68+
final String username = System.getenv("MVNW_USERNAME");
69+
final char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
10170
Authenticator.setDefault(new Authenticator() {
10271
@Override
10372
protected PasswordAuthentication getPasswordAuthentication() {
10473
return new PasswordAuthentication(username, password);
10574
}
10675
});
10776
}
108-
URL website = new URL(urlString);
109-
ReadableByteChannel rbc;
110-
rbc = Channels.newChannel(website.openStream());
111-
FileOutputStream fos = new FileOutputStream(destination);
112-
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113-
fos.close();
114-
rbc.close();
77+
Path temp = wrapperJarPath
78+
.getParent()
79+
.resolve(wrapperJarPath.getFileName() + "."
80+
+ Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp");
81+
try (InputStream inStream = wrapperUrl.openStream()) {
82+
Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING);
83+
Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING);
84+
} finally {
85+
Files.deleteIfExists(temp);
86+
}
87+
log(" - Downloader complete");
88+
}
89+
90+
private static void log(String msg) {
91+
if (VERBOSE) {
92+
System.out.println(msg);
93+
}
11594
}
11695

11796
}

.mvn/wrapper/maven-wrapper.jar

12.1 KB
Binary file not shown.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
1+
wrapperVersion=3.3.4
2+
distributionType=source
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
4+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## [Unreleased]
4+
- Bump httpclient from 4.5.14 to httpclient5 5.5.1
5+
- Bump various maven plugins
46

57
## [1.4.0] - 2025-07-24
68
- Bump testcontainers.version from 1.19.3 to 1.21.3

0 commit comments

Comments
 (0)