Skip to content

Commit 99862ff

Browse files
authored
Merge pull request #7 from protegeproject/github-workflow
updated github workflow
2 parents 498f586 + 8217833 commit 99862ff

File tree

4 files changed

+145
-137
lines changed

4 files changed

+145
-137
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
name: Java CI
1+
name: Verify
22

3-
on: [push]
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
47

58
jobs:
69
build:
710
runs-on: ubuntu-latest
811

912
steps:
1013
- uses: actions/checkout@v3
14+
with:
15+
token: ${{ secrets.GITHUB_TOKEN }}
1116
- name: Set up JDK 17
1217
uses: actions/setup-java@v3
1318
with:
1419
java-version: '17'
15-
distribution: 'temurin'
20+
distribution: 'adopt'
1621
- name: Build with Maven
17-
run: mvn --batch-mode --update-snapshots package
22+
run: mvn --batch-mode package

.github/workflows/pub-docker-hub.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- main-WHO
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.actor != 'protegeproject-bot[bot]' }}
13+
steps:
14+
- name: Login to Docker Hub
15+
uses: docker/login-action@v2
16+
with:
17+
username: ${{secrets.DOCKER_USERNAME}}
18+
password: ${{secrets.DOCKER_PASSWORD}}
19+
- uses: actions/create-github-app-token@v1
20+
id: app-token
21+
with:
22+
app-id: ${{ vars.PROTEGEPROJECT_BOT_APP_ID }}
23+
private-key: ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }}
24+
- uses: actions/checkout@v4
25+
with:
26+
token: ${{ steps.app-token.outputs.token }}
27+
ref: ${{ github.head_ref }}
28+
- name: Set up Maven Central Repository
29+
uses: actions/setup-java@v3
30+
with:
31+
java-version: '17'
32+
distribution: 'adopt'
33+
server-id: docker.io
34+
server-username: DOCKER_USERNAME
35+
server-password: DOCKER_PASSWORD
36+
- name: Get current version
37+
id: get-version
38+
run: |
39+
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
40+
echo "Current version: $current_version"
41+
echo "::set-output name=current_version::$current_version"
42+
- name: Bump version
43+
id: bump
44+
run: |
45+
current_version=${{ steps.get-version.outputs.current_version }}
46+
branch=${GITHUB_REF##*/}
47+
echo "Current branch: $branch"
48+
49+
# Extract the base version without suffix
50+
base_version=$(echo $current_version | sed -E 's/(-.*)?$//')
51+
52+
# Increment the base version (assuming semantic versioning)
53+
IFS='.' read -r -a version_parts <<< "$base_version"
54+
version_parts[2]=$((version_parts[2] + 1))
55+
new_base_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
56+
57+
if [[ "$branch" == "main-WHO" ]]; then
58+
new_version="${new_base_version}-WHO"
59+
else
60+
new_version="$new_base_version"
61+
fi
62+
63+
echo "New version: $new_version"
64+
mvn versions:set -DnewVersion=$new_version -DgenerateBackupPoms=false
65+
echo "::set-output name=new_version::$new_version"
66+
- name: Commit new version
67+
run: |
68+
git config --global user.name "github-actions[bot]"
69+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
70+
git add pom.xml
71+
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
72+
git tag ${{ steps.bump.outputs.new_version }}
73+
git push origin HEAD:${GITHUB_REF##*/}
74+
git push origin ${{ steps.bump.outputs.new_version }}
75+
- name: Build and Publish package
76+
run: mvn --batch-mode package install
77+
- name: Release
78+
uses: softprops/action-gh-release@v1
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
tag_name: ${{ steps.bump.outputs.new_version }}
83+
generate_release_notes: true
84+
85+
env:
86+
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
87+
DOCKER_TOKEN: ${{secrets.DOCKER_PASSWORD}}

pom.xml

Lines changed: 49 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -73,126 +73,71 @@
7373
</dependencies>
7474

7575
<build>
76+
7677
<plugins>
7778
<plugin>
7879
<groupId>org.springframework.boot</groupId>
7980
<artifactId>spring-boot-maven-plugin</artifactId>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-surefire-plugin</artifactId>
85+
<version>3.0.0</version>
8086
<configuration>
81-
<image>
82-
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
83-
</image>
87+
<systemPropertyVariables>
88+
<spring.profiles.active>test</spring.profiles.active>
89+
</systemPropertyVariables>
90+
<includes>
91+
<include>**/*TestCase.java</include>
92+
<include>**/*Test.java</include>
93+
<include>**/*IT.java</include>
94+
</includes>
8495
</configuration>
8596
</plugin>
8697
<plugin>
87-
<groupId>com.spotify</groupId>
88-
<artifactId>dockerfile-maven-plugin</artifactId>
89-
<version>1.4.13</version>
98+
<groupId>org.codehaus.mojo</groupId>
99+
<artifactId>exec-maven-plugin</artifactId>
100+
<version>3.3.0</version>
90101
<executions>
91102
<execution>
92-
<id>default</id>
103+
<id>docker-build</id>
104+
<phase>package</phase>
93105
<goals>
94-
<goal>build</goal>
106+
<goal>exec</goal>
95107
</goals>
108+
<configuration>
109+
<executable>docker</executable>
110+
<workingDirectory>${project.basedir}</workingDirectory>
111+
<arguments>
112+
<argument>build</argument>
113+
<argument>-f</argument>
114+
<argument>Dockerfile</argument>
115+
<argument>--build-arg</argument>
116+
<argument>JAR_FILE=${project.artifactId}-${project.version}.jar</argument>
117+
<argument>-t</argument>
118+
<argument>protegeproject/${project.artifactId}:${project.version}</argument>
119+
<argument>.</argument>
120+
</arguments>
121+
</configuration>
122+
</execution>
123+
<execution>
124+
<id>docker-push</id>
125+
<phase>install</phase>
126+
<goals>
127+
<goal>exec</goal>
128+
</goals>
129+
<configuration>
130+
<executable>docker</executable>
131+
<workingDirectory>${project.basedir}</workingDirectory>
132+
<arguments>
133+
<argument>push</argument>
134+
<argument>protegeproject/${project.artifactId}:${project.version}</argument>
135+
</arguments>
136+
</configuration>
96137
</execution>
97138
</executions>
98-
<configuration>
99-
<repository>protegeproject/${project.artifactId}</repository>
100-
<tag>${project.version}</tag>
101-
<buildArgs>
102-
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
103-
</buildArgs>
104-
<!-- <username>${env.DOCKER_USERNAME}</username>-->
105-
<!-- <password>${env.DOCKER_PASSWORD}</password>-->
106-
</configuration>
107139
</plugin>
108140
</plugins>
109141
</build>
110142

111-
<profiles>
112-
<profile>
113-
<id>release</id>
114-
<build>
115-
<plugins>
116-
<plugin>
117-
<groupId>org.apache.maven.plugins</groupId>
118-
<artifactId>maven-source-plugin</artifactId>
119-
<version>3.2.1</version>
120-
<executions>
121-
<execution>
122-
<id>attach-sources</id>
123-
<goals>
124-
<goal>jar-no-fork</goal>
125-
</goals>
126-
</execution>
127-
</executions>
128-
</plugin>
129-
130-
<plugin>
131-
<groupId>org.apache.maven.plugins</groupId>
132-
<artifactId>maven-javadoc-plugin</artifactId>
133-
<version>3.2.0</version>
134-
<configuration>
135-
<doclint>none</doclint>
136-
<release>16</release>
137-
</configuration>
138-
<executions>
139-
<execution>
140-
<id>attach-javadocs</id>
141-
<goals>
142-
<goal>jar</goal>
143-
</goals>
144-
</execution>
145-
</executions>
146-
</plugin>
147-
148-
<plugin>
149-
<groupId>org.apache.maven.plugins</groupId>
150-
<artifactId>maven-gpg-plugin</artifactId>
151-
<version>1.6</version>
152-
<executions>
153-
<execution>
154-
<id>sign-artifacts</id>
155-
<phase>verify</phase>
156-
<goals>
157-
<goal>sign</goal>
158-
</goals>
159-
<configuration>
160-
<gpgArguments>
161-
<arg>--pinentry-mode</arg>
162-
<arg>loopback</arg>
163-
</gpgArguments>
164-
</configuration>
165-
</execution>
166-
</executions>
167-
</plugin>
168-
169-
<plugin>
170-
<groupId>org.sonatype.plugins</groupId>
171-
<artifactId>nexus-staging-maven-plugin</artifactId>
172-
<version>1.6.7</version>
173-
<extensions>true</extensions>
174-
<configuration>
175-
<serverId>ossrh</serverId>
176-
<nexusUrl>https://oss.sonatype.org</nexusUrl>
177-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
178-
</configuration>
179-
<dependencies>
180-
<!--
181-
TODO:
182-
Remove after OSSRH-66257, NEXUS-26993 are fixed,
183-
possibly via https://github.com/sonatype/nexus-maven-plugins/pull/91
184-
-->
185-
<dependency>
186-
<groupId>com.thoughtworks.xstream</groupId>
187-
<artifactId>xstream</artifactId>
188-
<version>1.4.15</version>
189-
</dependency>
190-
</dependencies>
191-
</plugin>
192-
193-
</plugins>
194-
</build>
195-
</profile>
196-
</profiles>
197-
198143
</project>

0 commit comments

Comments
 (0)