Skip to content

Commit

Permalink
updated github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeo committed Sep 25, 2024
1 parent e2e3a9b commit cb1d8e8
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 167 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
name: Java CI

on: [push]
on:
push:
branches-ignore:
- main
- master-who

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
distribution: 'adopt'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots package
run: mvn --batch-mode package
29 changes: 0 additions & 29 deletions .github/workflows/pub-docker-hub.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/pub.yaml

This file was deleted.

89 changes: 89 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Release

on:
push:
branches:
- main
- master-who

jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.actor != 'protegeproject-bot[bot]' }}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.PROTEGEPROJECT_BOT_APP_ID }}
private-key: ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.head_ref }}
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
server-id: docker.io
server-username: DOCKER_USERNAME
server-password: DOCKER_PASSWORD
- name: Get current version
id: get-version
run: |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Current version: $current_version"
echo "::set-output name=current_version::$current_version"
- name: Bump version
id: bump
run: |
current_version=${{ steps.get-version.outputs.current_version }}
branch=${GITHUB_REF##*/}
echo "Current branch: $branch"
# Extract the base version without suffix
base_version=$(echo $current_version | sed -E 's/(-.*)?$//')
# Increment the base version (assuming semantic versioning)
IFS='.' read -r -a version_parts <<< "$base_version"
version_parts[2]=$((version_parts[2] + 1))
new_base_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
if [[ "$branch" == "master-who" ]]; then
new_version="${new_base_version}-WHO"
else
new_version="$new_base_version"
fi
echo "New version: $new_version"
find . -name 'pom.xml' -exec mvn versions:set -DnewVersion=$new_version -DgenerateBackupPoms=false -f {} \;
echo "::set-output name=new_version::$new_version"
- name: Commit new version
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
git tag ${{ steps.bump.outputs.new_version }}
git push origin HEAD:${GITHUB_REF##*/}
git push origin ${{ steps.bump.outputs.new_version }}
- name: Build package
run: mvn --batch-mode clean package
- name: Build and push image
run: mvn --batch-mode package install
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump.outputs.new_version }}
generate_release_notes: true

env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_TOKEN: ${{secrets.DOCKER_PASSWORD}}
142 changes: 35 additions & 107 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,121 +158,49 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>default</id>
<id>docker-build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>exec</goal>
</goals>
<configuration>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>build</argument>
<argument>-f</argument>
<argument>Dockerfile</argument>
<argument>--build-arg</argument>
<argument>JAR_FILE=${project.artifactId}-${project.version}.jar</argument>
<argument>-t</argument>
<argument>protegeproject/${project.artifactId}:${project.version}</argument>
<argument>.</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>docker-push</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>push</argument>
<argument>protegeproject/${project.artifactId}:${project.version}</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<repository>protegeproject/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<!-- <username>${env.DOCKER_USERNAME}</username>-->
<!-- <password>${env.DOCKER_PASSWORD}</password>-->
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<doclint>none</doclint>
<release>16</release>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
<dependencies>
<!--
TODO:
Remove after OSSRH-66257, NEXUS-26993 are fixed,
possibly via https://github.com/sonatype/nexus-maven-plugins/pull/91
-->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.15</version>
</dependency>
</dependencies>
</plugin>

</plugins>
</build>
</profile>
<profile>
<id>local</id>
<properties>
<spring.profiles.active>local</spring.profiles.active>
</properties>
</profile>
</profiles>

</project>

0 comments on commit cb1d8e8

Please sign in to comment.