Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated github workflow #6

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Java CI
name: Verify

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

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.

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

on:
push:
branches:
- main
- main-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" == "main-WHO" ]]; then
new_version="${new_base_version}-WHO"
else
new_version="$new_base_version"
fi

echo "New version: $new_version"
mvn versions:set -DnewVersion=$new_version -DgenerateBackupPoms=false
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 pom.xml
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 and Publish package
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}}
153 changes: 49 additions & 104 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,126 +73,71 @@
</dependencies>

<build>

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
</image>
<systemPropertyVariables>
<spring.profiles.active>test</spring.profiles.active>
</systemPropertyVariables>
<includes>
<include>**/*TestCase.java</include>
<include>**/*Test.java</include>
<include>**/*IT.java</include>
</includes>
</configuration>
</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>
</profiles>

</project>
Loading