Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 33c5bb6

Browse files
authored
feat: release workflow (#26)
1 parent c5d288e commit 33c5bb6

File tree

3 files changed

+137
-7
lines changed

3 files changed

+137
-7
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release to Maven Central
2+
env:
3+
MAVEN_ARGS: -V -ntp -e
4+
on:
5+
release:
6+
types: [ released ]
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Set up Java and Maven
13+
uses: actions/setup-java@v2
14+
with:
15+
java-version: 11
16+
distribution: temurin
17+
cache: 'maven'
18+
- name: change version to release version
19+
run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION}" versions:commit
20+
env:
21+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
22+
- name: Release Maven package
23+
uses: samuelmeuli/action-maven-publish@v1
24+
with:
25+
maven_profiles: "release"
26+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
28+
nexus_username: ${{ secrets.OSSRH_USERNAME }}
29+
nexus_password: ${{ secrets.OSSRH_TOKEN }}
30+
31+
# This is separate job because there were issues with git after release step, was not able to commit changes. See history.
32+
update-working-version:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Set up Java and Maven
37+
uses: actions/setup-java@v2
38+
with:
39+
java-version: 11
40+
distribution: temurin
41+
cache: 'maven'
42+
- name: change version to release version
43+
run: |
44+
./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION}" versions:commit
45+
./mvnw ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit
46+
git config --local user.email "[email protected]"
47+
git config --local user.name "GitHub Action"
48+
git commit -m "Set new SNAPSHOT version into pom files." -a
49+
env:
50+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
51+
- name: Push changes
52+
uses: ad-m/github-push-action@master
53+
with:
54+
github_token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# jenvtest
22

3-
Jenvtest is similar to envtest, to support unit testing with API Server - just for Java:
4-
https://book.kubebuilder.io/reference/envtest.html
3+
jenvtest makes it easy to implement integration tests with Kubernetes API Server in Java.
4+
Inspired by [envtest](https://book.kubebuilder.io/reference/envtest.html) in go.
55

66
It runs the API Server binaries directly (without nodes and other components). Thus, only etcd and Kubernetes API Server.
77
Linux, Windows, Mac is supported.
@@ -15,11 +15,13 @@ Project is in early phases, heading towards mvp release.
1515
See sample unit test [here](https://github.com/csviri/jenvtest/blob/main/src/test/java/com/csviri/jenvtest/junit/JUnitExtensionTest.java)
1616

1717
```java
18-
@EnableKubeAPIServer
18+
19+
@EnableKubeAPIServer // Start/Stop Kube API Server in the background
1920
class JUnitExtensionTest {
2021

2122
@Test
2223
void testCommunication() {
24+
// use a Kubernetes client to communicate with the server
2325
var client = new KubernetesClientBuilder().build();
2426
client.resource(configMap()).createOrReplace();
2527
var cm = client.resource(configMap()).get();
@@ -50,10 +52,18 @@ and/or
5052
You would probably use some additional framework to implement those hooks, like [kubernetes-webooks-framework](https://github.com/java-operator-sdk/kubernetes-webooks-framework)
5153
with Quarkus or Spring. However, we demonstrate how it works in [this test](https://github.com/csviri/jenvtest/blob/main/src/test/java/com/csviri/jenvtest/KubernetesMutationHookHandlingTest.java)
5254

53-
### Download binaries
55+
### How does it work
5456

55-
Binaries are downloaded automatically under $JENVTEST_DIR/k8s/[target-platform-and-version].
57+
In the background Kubernetes and etcd (and kubectl) binaries are downloaded if not found locally.
58+
59+
All the certificates for the Kube API Server and for the client is generated. The client config file
60+
(`~/kube/config`) file is updated, to any client can be used to talk to the API Server.
61+
62+
#### Downloading binaries
63+
64+
Binaries are downloaded automatically under ~/.jenvtest/k8s/[target-platform-and-version].
5665

5766
Also [`setup-envtest`](https://pkg.go.dev/sigs.k8s.io/controller-runtime/tools/setup-envtest#section-readme) can be used
5867
to download binaries manually. By executing `setup-envtest use --bin-dir ~/.jenvtest` will download the latest required
5968
binaries to the default directory.
69+

pom.xml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6-
<groupId>io.csviri.jenvtest</groupId>
6+
<groupId>io.javaoperatorsdk</groupId>
77
<artifactId>jenvtest</artifactId>
88
<version>0.0.1-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>jenvtest</name>
12-
<description>Java Wrapper Utility for Kubernetes API Server</description>
12+
<description>Library to support testing against Kubernetes API server</description>
1313

1414
<properties>
1515
<junit.version>5.9.1</junit.version>
@@ -34,6 +34,8 @@
3434
<directory-maven-plugin.version>1.0</directory-maven-plugin.version>
3535
<jetty.version>11.0.14</jetty.version>
3636
<kubernetes.webhooks.framework.version>1.0.0</kubernetes.webhooks.framework.version>
37+
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
38+
<maven-javadoc-plugin.version>3.5.0</maven-javadoc-plugin.version>
3739
</properties>
3840

3941
<dependencyManagement>
@@ -212,4 +214,68 @@
212214
</plugin>
213215
</plugins>
214216
</build>
217+
<profiles>
218+
<profile>
219+
<id>release</id>
220+
<build>
221+
<plugins>
222+
<plugin>
223+
<groupId>org.apache.maven.plugins</groupId>
224+
<artifactId>maven-javadoc-plugin</artifactId>
225+
<version>${maven-javadoc-plugin.version}</version>
226+
<executions>
227+
<execution>
228+
<id>attach-javadocs</id>
229+
<goals>
230+
<goal>jar</goal>
231+
</goals>
232+
</execution>
233+
</executions>
234+
</plugin>
235+
<plugin>
236+
<groupId>org.apache.maven.plugins</groupId>
237+
<artifactId>maven-source-plugin</artifactId>
238+
<executions>
239+
<execution>
240+
<id>attach-sources</id>
241+
<goals>
242+
<goal>jar</goal>
243+
</goals>
244+
</execution>
245+
</executions>
246+
</plugin>
247+
<plugin>
248+
<groupId>org.apache.maven.plugins</groupId>
249+
<artifactId>maven-gpg-plugin</artifactId>
250+
<executions>
251+
<execution>
252+
<id>sign-artifacts</id>
253+
<phase>verify</phase>
254+
<goals>
255+
<goal>sign</goal>
256+
</goals>
257+
<configuration>
258+
<gpgArguments>
259+
<arg>--pinentry-mode</arg>
260+
<arg>loopback</arg>
261+
</gpgArguments>
262+
</configuration>
263+
</execution>
264+
</executions>
265+
</plugin>
266+
<plugin>
267+
<groupId>org.sonatype.plugins</groupId>
268+
<artifactId>nexus-staging-maven-plugin</artifactId>
269+
<version>${nexus-staging-maven-plugin.version}</version>
270+
<extensions>true</extensions>
271+
<configuration>
272+
<serverId>ossrh</serverId>
273+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
274+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
275+
</configuration>
276+
</plugin>
277+
</plugins>
278+
</build>
279+
</profile>
280+
</profiles>
215281
</project>

0 commit comments

Comments
 (0)