Skip to content

Commit cb1d8e8

Browse files
committed
updated github workflows
1 parent e2e3a9b commit cb1d8e8

File tree

5 files changed

+133
-167
lines changed

5 files changed

+133
-167
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
name: Java CI
2-
3-
on: [push]
1+
on:
2+
push:
3+
branches-ignore:
4+
- main
5+
- master-who
46

57
jobs:
68
build:
79
runs-on: ubuntu-latest
810

911
steps:
1012
- uses: actions/checkout@v3
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
1115
- name: Set up JDK 17
1216
uses: actions/setup-java@v3
1317
with:
1418
java-version: '17'
15-
distribution: 'temurin'
19+
distribution: 'adopt'
1620
- name: Build with Maven
17-
run: mvn --batch-mode --update-snapshots package
21+
run: mvn --batch-mode package

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

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

.github/workflows/pub.yaml

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

.github/workflows/release.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master-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" == "master-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+
find . -name 'pom.xml' -exec mvn versions:set -DnewVersion=$new_version -DgenerateBackupPoms=false -f {} \;
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 .
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 package
76+
run: mvn --batch-mode clean package
77+
- name: Build and push image
78+
run: mvn --batch-mode package install
79+
- name: Release
80+
uses: softprops/action-gh-release@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
tag_name: ${{ steps.bump.outputs.new_version }}
85+
generate_release_notes: true
86+
87+
env:
88+
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
89+
DOCKER_TOKEN: ${{secrets.DOCKER_PASSWORD}}

pom.xml

Lines changed: 35 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -158,121 +158,49 @@
158158
<artifactId>spring-boot-maven-plugin</artifactId>
159159
</plugin>
160160
<plugin>
161-
<groupId>com.spotify</groupId>
162-
<artifactId>dockerfile-maven-plugin</artifactId>
163-
<version>1.4.13</version>
161+
<groupId>org.codehaus.mojo</groupId>
162+
<artifactId>exec-maven-plugin</artifactId>
163+
<version>3.3.0</version>
164164
<executions>
165165
<execution>
166-
<id>default</id>
166+
<id>docker-build</id>
167+
<phase>package</phase>
167168
<goals>
168-
<goal>build</goal>
169+
<goal>exec</goal>
169170
</goals>
171+
<configuration>
172+
<executable>docker</executable>
173+
<workingDirectory>${project.basedir}</workingDirectory>
174+
<arguments>
175+
<argument>build</argument>
176+
<argument>-f</argument>
177+
<argument>Dockerfile</argument>
178+
<argument>--build-arg</argument>
179+
<argument>JAR_FILE=${project.artifactId}-${project.version}.jar</argument>
180+
<argument>-t</argument>
181+
<argument>protegeproject/${project.artifactId}:${project.version}</argument>
182+
<argument>.</argument>
183+
</arguments>
184+
</configuration>
185+
</execution>
186+
<execution>
187+
<id>docker-push</id>
188+
<phase>install</phase>
189+
<goals>
190+
<goal>exec</goal>
191+
</goals>
192+
<configuration>
193+
<executable>docker</executable>
194+
<workingDirectory>${project.basedir}</workingDirectory>
195+
<arguments>
196+
<argument>push</argument>
197+
<argument>protegeproject/${project.artifactId}:${project.version}</argument>
198+
</arguments>
199+
</configuration>
170200
</execution>
171201
</executions>
172-
<configuration>
173-
<repository>protegeproject/${project.artifactId}</repository>
174-
<tag>${project.version}</tag>
175-
<buildArgs>
176-
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
177-
</buildArgs>
178-
<!-- <username>${env.DOCKER_USERNAME}</username>-->
179-
<!-- <password>${env.DOCKER_PASSWORD}</password>-->
180-
</configuration>
181202
</plugin>
182203
</plugins>
183204
</build>
184205

185-
<profiles>
186-
<profile>
187-
<id>release</id>
188-
<build>
189-
<plugins>
190-
<plugin>
191-
<groupId>org.apache.maven.plugins</groupId>
192-
<artifactId>maven-source-plugin</artifactId>
193-
<version>3.2.1</version>
194-
<executions>
195-
<execution>
196-
<id>attach-sources</id>
197-
<goals>
198-
<goal>jar-no-fork</goal>
199-
</goals>
200-
</execution>
201-
</executions>
202-
</plugin>
203-
204-
<plugin>
205-
<groupId>org.apache.maven.plugins</groupId>
206-
<artifactId>maven-javadoc-plugin</artifactId>
207-
<version>3.2.0</version>
208-
<configuration>
209-
<doclint>none</doclint>
210-
<release>16</release>
211-
</configuration>
212-
<executions>
213-
<execution>
214-
<id>attach-javadocs</id>
215-
<goals>
216-
<goal>jar</goal>
217-
</goals>
218-
</execution>
219-
</executions>
220-
</plugin>
221-
222-
<plugin>
223-
<groupId>org.apache.maven.plugins</groupId>
224-
<artifactId>maven-gpg-plugin</artifactId>
225-
<version>1.6</version>
226-
<executions>
227-
<execution>
228-
<id>sign-artifacts</id>
229-
<phase>verify</phase>
230-
<goals>
231-
<goal>sign</goal>
232-
</goals>
233-
<configuration>
234-
<gpgArguments>
235-
<arg>--pinentry-mode</arg>
236-
<arg>loopback</arg>
237-
</gpgArguments>
238-
</configuration>
239-
</execution>
240-
</executions>
241-
</plugin>
242-
243-
<plugin>
244-
<groupId>org.sonatype.plugins</groupId>
245-
<artifactId>nexus-staging-maven-plugin</artifactId>
246-
<version>1.6.7</version>
247-
<extensions>true</extensions>
248-
<configuration>
249-
<serverId>ossrh</serverId>
250-
<nexusUrl>https://oss.sonatype.org</nexusUrl>
251-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
252-
</configuration>
253-
<dependencies>
254-
<!--
255-
TODO:
256-
Remove after OSSRH-66257, NEXUS-26993 are fixed,
257-
possibly via https://github.com/sonatype/nexus-maven-plugins/pull/91
258-
-->
259-
<dependency>
260-
<groupId>com.thoughtworks.xstream</groupId>
261-
<artifactId>xstream</artifactId>
262-
<version>1.4.15</version>
263-
</dependency>
264-
</dependencies>
265-
</plugin>
266-
267-
</plugins>
268-
</build>
269-
</profile>
270-
<profile>
271-
<id>local</id>
272-
<properties>
273-
<spring.profiles.active>local</spring.profiles.active>
274-
</properties>
275-
</profile>
276-
</profiles>
277-
278206
</project>

0 commit comments

Comments
 (0)