Skip to content

Commit

Permalink
Branch name is now extracted by GitHub action instead of maven plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianWenzel committed Apr 11, 2024
1 parent a948ea2 commit 264e638
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 62 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/java-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,35 @@ jobs:
java-version: "${{ inputs.java-version }}"
distribution: 'temurin'
cache: maven

- name: Extract branch or tag name
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
NORMALIZED_BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
echo "NORMALIZED_BRANCH_NAME=$NORMALIZED_BRANCH_NAME" >> $GITHUB_ENV
fi
shell: bash

- name: Determine changelist
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
CHANGELIST=''
else
CHANGELIST=$(test "${GITHUB_REF#refs/heads/}" == 'master' && echo '' || echo "-$NORMALIZED_BRANCH_NAME-SNAPSHOT")
fi
echo "CHANGELIST=$CHANGELIST" >> $GITHUB_ENV
shell: bash

- name: Build with Maven
run: mvn ${{ inputs.maven-options }} -B package --file pom.xml
run: mvn ${{ inputs.maven-options }} --no-transfer-progress -B package --file pom.xml -Dchangelist=${CHANGELIST}
- name: Prepare artifact for upload
if: github.actor != 'dependabot[bot]'
if: ${{ github.actor != 'dependabot[bot]' }}
run: mkdir staging && cp target/*.zip staging
- name: Upload artifact
if: github.actor != 'dependabot[bot]'
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/upload-artifact@v4
with:
name: maven-build
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
uses: ./.github/workflows/java-build.yml
with:
java-version: 17
maven-options: "-P release"
release-job:
needs: build-job
name: Create Release
Expand Down
60 changes: 2 additions & 58 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@
<artifactId>neo2rdf</artifactId>
<version>${revision}</version>

<profiles>
<profile>
<id>release</id>
<properties>
<revision>${version}</revision>
</properties>
</profile>
</profiles>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<!--suppress UnresolvedMavenProperty -->
<sha1>${git.branch}</sha1>
<version>1.0.0</version>
<sha1>-LOCALBUILD</sha1>
<changelist/>
<revision>${version}-${sha1}${changelist}-SNAPSHOT</revision>
<revision>1.0.0${sha1}${changelist}</revision>
<version.mvn.plugin.flatten>1.1.0</version.mvn.plugin.flatten>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<neo4j.version>5.18.1</neo4j.version>
Expand Down Expand Up @@ -67,51 +56,6 @@
<artifactId>license-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/io.github.git-commit-id/git-commit-id-maven-plugin -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>7.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.directory}/git.properties
</generateGitPropertiesFilename>
<injectAllReactorProjects>true</injectAllReactorProjects>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
<includeOnlyProperty>^git.branch</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<replacementProperties>
<replacementProperty>
<property>git.branch</property>
<token>^([^\/]*)\/([^\/]*)$</token>
<value>$1-$2</value>
<regex>true</regex>
<transformationRules>
<transformationRule>
<apply>BEFORE</apply>
<action>UPPER_CASE</action>
</transformationRule>
<transformationRule>
<apply>AFTER</apply>
<action>LOWER_CASE</action>
</transformationRule>
</transformationRules>
</replacementProperty>
</replacementProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down

0 comments on commit 264e638

Please sign in to comment.