Skip to content

Commit

Permalink
chore: improve pom version check ✅ avoid github actions failure whe…
Browse files Browse the repository at this point in the history
…n release version tag
  • Loading branch information
oldratlee committed Apr 11, 2024
1 parent 859aa47 commit 5baf4bd
Showing 1 changed file with 22 additions and 30 deletions.
52 changes: 22 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>false</maven.deploy.skip>
<perform.release.jdk.version>17</perform.release.jdk.version>
<maven.enforcer.pom.version.regex>^\d(\.\d+)?\.(\d+|x)-SNAPSHOT$</maven.enforcer.pom.version.regex>
<release.pom.version.regex>^\d\.\d+\.\d+(-(Alpha|Beta|RC)\d+)?$</release.pom.version.regex>

<spotbugs.annotations.version>4.8.4</spotbugs.annotations.version>
<jsr305.version>3.0.2</jsr305.version>
Expand Down Expand Up @@ -292,8 +294,8 @@
<!-- https://maven.apache.org/enforcer/enforcer-rules/requireProperty.html -->
<requireProperty>
<property>project.version</property>
<regex>^\d(\.\d+)?\.(\d+|x)-SNAPSHOT$</regex>
<regexMessage>Project dev version(${project.version}) format is invalid!</regexMessage>
<regex>${maven.enforcer.pom.version.regex}</regex>
<regexMessage>Project version(${project.version}) format is invalid!</regexMessage>
</requireProperty>
</rules>
</configuration>
Expand Down Expand Up @@ -724,6 +726,7 @@
</plugins>
</build>
</profile>

<profile>
<id>enforce-project-version-when-release</id>
<activation>
Expand All @@ -732,35 +735,24 @@
<value>true</value>
</property>
</activation>
<build>
<plugins>
<!--
add maven-enforce-plugin to make sure the right jdk is used
https://stackoverflow.com/a/18420462/922688
-->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforces</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>project.version</property>
<regex>^\d\.\d+\.\d+(-(Alpha|Beta|RC)\d+)?$</regex>
<regexMessage>Project release version(${project.version}) format is invalid!</regexMessage>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.enforcer.pom.version.regex>${release.pom.version.regex}</maven.enforcer.pom.version.regex>
</properties>
</profile>
<profile>
<id>enforce-project-version-when-github-action-triggered-by-tag</id>
<activation>
<property>
<!-- https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables -->
<name>env.GITHUB_REF_TYPE</name>
<value>tag</value>
</property>
</activation>
<properties>
<maven.enforcer.pom.version.regex>${release.pom.version.regex}</maven.enforcer.pom.version.regex>
</properties>
</profile>

<profile>
<id>deploy-settings</id>
<activation>
Expand Down

0 comments on commit 5baf4bd

Please sign in to comment.