Skip to content

Commit 56ca97f

Browse files
authored
feat: ci release piplines (#14)
1 parent 92ebf64 commit 56ca97f

File tree

8 files changed

+128
-25
lines changed

8 files changed

+128
-25
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test & Release Snapshot to Maven Central
2+
3+
env:
4+
MAVEN_ARGS: -V -ntp -e
5+
6+
concurrency:
7+
group: ${{ github.ref }}-${{ github.workflow }}
8+
cancel-in-progress: true
9+
on:
10+
push:
11+
branches: [ main ]
12+
workflow_dispatch:
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
java: [ 11, 17 ]
19+
distribution: [ temurin ]
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Java and Maven
23+
uses: actions/setup-java@v2
24+
with:
25+
distribution: ${{ matrix.distribution }}
26+
java-version: ${{ matrix.java }}
27+
cache: 'maven'
28+
- name: Run unit tests
29+
run: ./mvnw ${MAVEN_ARGS} -B test --file pom.xml
30+
- name: Run integration tests
31+
run: ./mvnw ${MAVEN_ARGS} -B package --file pom.xml
32+
release-snapshot:
33+
runs-on: ubuntu-latest
34+
needs: test
35+
steps:
36+
- uses: actions/checkout@v2
37+
- name: Set up Java and Maven
38+
uses: actions/setup-java@v2
39+
with:
40+
distribution: temurin
41+
java-version: 11
42+
cache: 'maven'
43+
- name: Release Maven package
44+
uses: samuelmeuli/action-maven-publish@v1
45+
with:
46+
maven_profiles: "release"
47+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
48+
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
49+
nexus_username: ${{ secrets.OSSRH_USERNAME }}
50+
nexus_password: ${{ secrets.OSSRH_TOKEN }}
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Run Tests
1+
name: Verify Pull Request
22

33
env:
44
MAVEN_ARGS: -V -ntp -e
@@ -7,13 +7,11 @@ concurrency:
77
group: ${{ github.ref }}-${{ github.workflow }}
88
cancel-in-progress: true
99
on:
10-
push:
11-
branches: [ main ]
1210
pull_request:
13-
types: [ opened, synchronize, reopened ]
14-
11+
branches: [ main ]
12+
workflow_dispatch:
1513
jobs:
16-
test:
14+
build:
1715
runs-on: ubuntu-latest
1816
strategy:
1917
matrix:
@@ -27,15 +25,9 @@ jobs:
2725
distribution: ${{ matrix.distribution }}
2826
java-version: ${{ matrix.java }}
2927
cache: 'maven'
30-
- name: Cache Maven packages
31-
uses: actions/cache@v1
32-
with:
33-
path: ~/.m2
34-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
35-
restore-keys: ${{ runner.os }}-m2
36-
- name: Build and analyze
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
39-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
28+
- name: Check code format
29+
run: |
30+
./mvnw ${MAVEN_ARGS} formatter:validate -Dconfigfile=$PWD/contributing/eclipse-google-style.xml --file pom.xml
31+
./mvnw ${MAVEN_ARGS} impsort:check --file pom.xml
32+
- name: Run unit tests
4033
run: ./mvnw ${MAVEN_ARGS} -B test --file pom.xml
41-

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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@v2
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+
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
20+
run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
21+
env:
22+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
23+
- name: Release Maven package
24+
uses: samuelmeuli/action-maven-publish@v1
25+
with:
26+
maven_profiles: "release"
27+
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
28+
# gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
29+
nexus_username: ${{ secrets.OSSRH_USERNAME }}
30+
nexus_password: ${{ secrets.OSSRH_TOKEN }}
31+
32+
# This is separate job because there were issues with git after release step, was not able to commit changes. See history.
33+
update-working-version:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v2
37+
- name: Set up Java and Maven
38+
uses: actions/setup-java@v2
39+
with:
40+
java-version: 11
41+
distribution: temurin
42+
cache: 'maven'
43+
- name: change version to release version
44+
run: |
45+
./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
46+
./mvnw ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit
47+
git config --local user.email "[email protected]"
48+
git config --local user.name "GitHub Action"
49+
git commit -m "Set new SNAPSHOT version into pom files." -a
50+
env:
51+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
52+
- name: Push changes v2
53+
uses: ad-m/github-push-action@master
54+
with:
55+
github_token: ${{ secrets.GITHUB_TOKEN }}

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.javaoperatorsdk</groupId>
88
<artifactId>admission-controller-framework</artifactId>
9-
<version>0.0.1-SNAPSHOT</version>
9+
<version>0.1.0-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>operator-framework-framework-core</artifactId>

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>io.javaoperatorsdk</groupId>
77
<artifactId>admission-controller-framework</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>0.1.0-SNAPSHOT</version>
99
<name>Admission Controller Framework for Java</name>
1010
<description>Framework to Implement Admission Controllers in Java</description>
1111
<packaging>pom</packaging>
@@ -24,6 +24,13 @@
2424
<url>https://github.com/java-operator-sdk/admission-controller-framework/tree/master</url>
2525
</scm>
2626

27+
<developers>
28+
<developer>
29+
<name>Attila Mészáros</name>
30+
<email>[email protected]</email>
31+
</developer>
32+
</developers>
33+
2734
<properties>
2835
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2936
<java.version>11</java.version>
@@ -191,7 +198,6 @@
191198
</plugins>
192199
</pluginManagement>
193200
<plugins>
194-
195201
<plugin>
196202
<groupId>org.commonjava.maven.plugins</groupId>
197203
<artifactId>directory-maven-plugin</artifactId>

samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>io.javaoperatorsdk</groupId>
77
<artifactId>admission-controller-framework</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>0.1.0-SNAPSHOT</version>
99
</parent>
1010
<artifactId>operator-framework-framework-samples</artifactId>
1111
<packaging>pom</packaging>

samples/quarkus/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>io.javaoperatorsdk</groupId>
77
<artifactId>operator-framework-framework-samples</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>0.1.0-SNAPSHOT</version>
99
</parent>
1010
<groupId>io.javaoperatorsdk.admissioncontroller.sample</groupId>
1111
<artifactId>quarkus-sample</artifactId>

samples/spring-boot/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>io.javaoperatorsdk</groupId>
77
<artifactId>operator-framework-framework-samples</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>0.1.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>io.javaoperatorsdk.admissioncontroller.sample</groupId>
1212
<artifactId>spring-boot-sample</artifactId>
13-
<version>0.0.1-SNAPSHOT</version>
13+
<version>0.1.0-SNAPSHOT</version>
1414
<name>Admission Controller Framework - Samples - Spring Boot</name>
1515

1616
<properties>
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>io.javaoperatorsdk</groupId>
4949
<artifactId>operator-framework-framework-core</artifactId>
50-
<version>0.0.1-SNAPSHOT</version>
50+
<version>0.1.0-SNAPSHOT</version>
5151
</dependency>
5252
</dependencies>
5353

0 commit comments

Comments
 (0)