Skip to content

Commit

Permalink
TASK-4017 added github workflow for building and release
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf2323 committed Mar 15, 2024
1 parent 305cc2f commit 266e485
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 47 deletions.
51 changes: 43 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,30 @@ on:
- '**'

jobs:
build:
name: Build
build_feature_branch:
name: Build feature branch
runs-on: ubuntu-latest

if: "github.ref != 'refs/heads/main'"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java and Maven
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Build with Maven verify
run: ./mvnw -B verify
build_main_branch:
name: Build main branch
runs-on: ubuntu-latest
if: "github.ref == 'refs/heads/main'"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java and Maven
uses: actions/setup-java@v4
with:
Expand All @@ -23,9 +40,27 @@ jobs:
server-id: 'reload'
server-username: ${{ secrets.MAVEN_SERVER_USERNAME }}
server-password: ${{ secrets.MAVEN_SERVER_PASSWORD }}
- name: Build with Maven verify
if: "github.ref != 'refs/heads/main'"
run: ./mvnw -B verify
- name: Read revision version from pom.xml
shell: bash
run: |
MAVEN_POM_REVISION_VERSION="$(./mvnw help:evaluate -Dexpression=revision -q -DforceStdout)"
echo "MAVEN_POM_REVISION_VERSION=$MAVEN_POM_REVISION_VERSION" >> $GITHUB_ENV
- name: Check if revision is already tagged
shell: bash
run: |
if git tag -l v$MAVEN_POM_REVISION_VERSION | grep -q v$MAVEN_POM_REVISION_VERSION; then
echo "Revision $MAVEN_POM_REVISION_VERSION is already tagged. Skipping the build and deployment!"
exit 0
else
DEPLOY_RELEASE=true
echo "DEPLOY_RELEASE=$DEPLOY_RELEASE" >> $GITHUB_ENV
fi
- name: Build with Maven deploy
if: "github.ref == 'refs/heads/main'"
run: ./mvnw -B deploy
if: ${{ env.DEPLOY_RELEASE == 'true' }}
run: ./mvnw -Dchangelist= -B deploy
- name: Create new git tag
uses: rickstaa/action-create-tag@v1
if: ${{ env.DEPLOY_RELEASE == 'true' }}
with:
tag: ${{ env.MAVEN_POM_REVISION_VERSION }}
message: Release ${{ env.MAVEN_POM_REVISION_VERSION }}
8 changes: 7 additions & 1 deletion Configs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
<parent>
<groupId>works.reload</groupId>
<artifactId>versions</artifactId>
<version>${revision}</version>
<version>${revision}${changelist}</version>
<relativePath>../Versions/pom.xml</relativePath>
</parent>

<artifactId>configs</artifactId>
<name>Configs</name>
<description>Global configurations for java tooling</description>

<properties>
<!-- project version -->
<revision>1.0.0</revision>
<changelist>-SNAPSHOT</changelist>
</properties>

<build>
<resources>
<resource>
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help \
update-dependencies update-snapshot-dependencies
update-dependencies update-snapshot-dependencies bump-version

help: ## This help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
Expand All @@ -15,3 +15,6 @@ update-dependencies: ## Update Maven dependencies and plugins which have version

update-snapshot-dependencies: ## Update locked snapshot versions with the latest available one in the POM
./mvnw --projects :base,:versions versions:unlock-snapshots versions:lock-snapshots

bump-version: ## Bump the version of the project
[ -n "$(NEW_VERSION)" ] && ./mvnw versions:set-property -Dproperty=revision -DnewVersion=$(NEW_VERSION)
39 changes: 38 additions & 1 deletion Versions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>works.reload</groupId>
<artifactId>versions</artifactId>
<version>${revision}</version>
<version>${revision}${changelist}</version>
<packaging>pom</packaging>
<name>Versions</name>
<description>All default maven versions</description>
Expand All @@ -17,9 +17,13 @@
</organization>

<properties>
<!-- project version -->
<revision>1.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<!-- project settings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<!-- plugin versions -->
<maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
<maven-assembly-plugin.version>3.7.0</maven-assembly-plugin.version>
<maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version>
Expand All @@ -32,6 +36,7 @@
<maven-install-plugin.version>3.1.1</maven-install-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<maven-site-plugin.version>4.0.0-M13</maven-site-plugin.version>
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -99,7 +104,39 @@
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
43 changes: 7 additions & 36 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>works.reload</groupId>
<artifactId>versions</artifactId>
<version>${revision}</version>
<version>${revision}${changelist}</version>
<relativePath>./Versions/pom.xml</relativePath>
</parent>

Expand All @@ -16,7 +16,9 @@
<description>Global configurations for java projects and code validation tools</description>

<properties>
<works-reload-configs.version>1.0.0</works-reload-configs.version>
<!-- project version -->
<revision>1.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<!-- dependencyManagement versions -->
<jetbrains-annotations.version>24.1.0</jetbrains-annotations.version>
<spotbugs-annotations.version>4.8.3</spotbugs-annotations.version>
Expand All @@ -41,7 +43,6 @@
<cobertura-maven-plugin.version>2.7</cobertura-maven-plugin.version>
<pitest-maven.version>1.15.8</pitest-maven.version>
<pitest-junit5-plugin.version>1.2.1</pitest-junit5-plugin.version>
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
<versions-maven-plugin.version>2.16.2</versions-maven-plugin.version>
</properties>

Expand Down Expand Up @@ -219,7 +220,7 @@
<dependency>
<groupId>works.reload</groupId>
<artifactId>configs</artifactId>
<version>${works-reload-configs.version}</version>
<version>${revision}${changelist}</version>
</dependency>
</dependencies>
<configuration>
Expand All @@ -238,7 +239,7 @@
<dependency>
<groupId>works.reload</groupId>
<artifactId>configs</artifactId>
<version>${works-reload-configs.version}</version>
<version>${revision}${changelist}</version>
</dependency>
</dependencies>
<configuration>
Expand All @@ -260,7 +261,7 @@
<dependency>
<groupId>works.reload</groupId>
<artifactId>configs</artifactId>
<version>${works-reload-configs.version}</version>
<version>${revision}${changelist}</version>
</dependency>
</dependencies>
<configuration>
Expand Down Expand Up @@ -295,11 +296,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand Down Expand Up @@ -447,31 +443,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand Down

0 comments on commit 266e485

Please sign in to comment.