diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a802b6..6be82fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: @@ -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 }} diff --git a/Configs/pom.xml b/Configs/pom.xml index f14f0c7..7b2d90f 100644 --- a/Configs/pom.xml +++ b/Configs/pom.xml @@ -6,7 +6,7 @@ works.reload versions - ${revision} + ${revision}${changelist} ../Versions/pom.xml @@ -14,6 +14,12 @@ Configs Global configurations for java tooling + + + 1.0.0 + -SNAPSHOT + + diff --git a/Makefile b/Makefile index cbf0d24..f4c86ac 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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) diff --git a/Versions/pom.xml b/Versions/pom.xml index 8f8b9a4..27cbcee 100644 --- a/Versions/pom.xml +++ b/Versions/pom.xml @@ -5,7 +5,7 @@ works.reload versions - ${revision} + ${revision}${changelist} pom Versions All default maven versions @@ -17,9 +17,13 @@ + 1.0.0 + -SNAPSHOT + UTF-8 17 + 3.1.0 3.7.0 3.6.1 @@ -32,6 +36,7 @@ 3.1.1 3.1.1 4.0.0-M13 + 1.6.0 @@ -99,7 +104,39 @@ maven-site-plugin ${maven-site-plugin.version} + + org.codehaus.mojo + flatten-maven-plugin + ${flatten-maven-plugin.version} + + + + org.codehaus.mojo + flatten-maven-plugin + + true + resolveCiFriendliesOnly + ${project.build.directory} + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + diff --git a/pom.xml b/pom.xml index b1c6188..f6d15e9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ works.reload versions - ${revision} + ${revision}${changelist} ./Versions/pom.xml @@ -16,7 +16,9 @@ Global configurations for java projects and code validation tools - 1.0.0 + + 1.0.0 + -SNAPSHOT 24.1.0 4.8.3 @@ -41,7 +43,6 @@ 2.7 1.15.8 1.2.1 - 1.6.0 2.16.2 @@ -219,7 +220,7 @@ works.reload configs - ${works-reload-configs.version} + ${revision}${changelist} @@ -238,7 +239,7 @@ works.reload configs - ${works-reload-configs.version} + ${revision}${changelist} @@ -260,7 +261,7 @@ works.reload configs - ${works-reload-configs.version} + ${revision}${changelist} @@ -295,11 +296,6 @@ - - org.codehaus.mojo - flatten-maven-plugin - ${flatten-maven-plugin.version} - org.codehaus.mojo versions-maven-plugin @@ -447,31 +443,6 @@ - - org.codehaus.mojo - flatten-maven-plugin - - true - resolveCiFriendliesOnly - ${project.build.directory} - - - - flatten - process-resources - - flatten - - - - flatten.clean - clean - - clean - - - - org.codehaus.mojo versions-maven-plugin