diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 390a20f..daf4ae8 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -8,7 +8,26 @@ on: - master jobs: - build-and-upload: - uses: ./.github/workflows/java-build.yml - with: - java-version: 17 + dev-build: + name: "Build Artifacts" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/mvn-setup + + - name: Build with Maven + run: mvn --no-transfer-progress -B package --file pom.xml -Dchangelist=${CHANGELIST} + + - name: Get artifact path + if: ${{ github.actor != 'dependabot[bot]' }} + run: | + echo "build_name=neo2rdf-build_${{ env.NORMALIZED_BRANCH_NAME }}" >> $GITHUB_ENV + echo "build_path=$(ls target/*.zip | head -n 1)" >> $GITHUB_ENV + + - name: Upload RDF build + uses: actions/upload-artifact@v4 + if: ${{ github.actor != 'dependabot[bot]' }} + with: + name: ${{ env.build_name }} + path: ${{ env.build_path }} diff --git a/.github/workflows/java-build.yml b/.github/workflows/java-build.yml deleted file mode 100644 index 023af2d..0000000 --- a/.github/workflows/java-build.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: build-artifact -on: - workflow_call: - inputs: - java-version: - description: "Java version to use" - required: true - type: string - maven-options: - required: false - type: string - default: "" - -jobs: - build: - name: "Build artifact" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - java-version: "${{ inputs.java-version }}" - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn ${{ inputs.maven-options }} -B package --file pom.xml - - name: Prepare artifact for upload - if: github.actor != 'dependabot[bot]' - run: mkdir staging && cp target/*.zip staging - - name: Upload artifact - if: github.actor != 'dependabot[bot]' - uses: actions/upload-artifact@v4 - with: - name: maven-build - path: staging diff --git a/.github/workflows/mvn-setup/action.yml b/.github/workflows/mvn-setup/action.yml new file mode 100644 index 0000000..01279ff --- /dev/null +++ b/.github/workflows/mvn-setup/action.yml @@ -0,0 +1,35 @@ +name: "Setup Environment" +description: "Sets up the environment to build the Java project with maven" +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + 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 + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8344955..4f9b55e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,40 +5,24 @@ on: - 'v*' jobs: - build-job: - uses: ./.github/workflows/java-build.yml - with: - java-version: 17 - maven-options: "-P release" release-job: - needs: build-job name: Create Release runs-on: ubuntu-latest steps: - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: maven-build - path: release-artifacts/ - - name: Get path name of artifact - run: echo "ARTIFACT_PATHNAME=$(ls release-artifacts/*.zip | head -n 1)" >> $GITHUB_ENV - - name: Get basename of artifact path - run: echo "ARTIFACT_NAME=$(basename ${{ env.ARTIFACT_PATHNAME }})" >> $GITHUB_ENV - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/mvn-setup + + - name: Build with Maven + run: mvn --no-transfer-progress -B package --file pom.xml -Dchangelist=${CHANGELIST} + + - name: Get artifact path + run: | + echo "build_name=neo2rdf-build_${{ env.NORMALIZED_BRANCH_NAME }}" >> $GITHUB_ENV + echo "build_path=$(ls target/*.zip | head -n 1)" >> $GITHUB_ENV + + - name: Create release + uses: softprops/action-gh-release@v1 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ env.ARTIFACT_PATHNAME }} - asset_name: ${{ env.ARTIFACT_NAME }} - asset_content_type: application/zip + files: | + ${{ env.build_path }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7af32c5..f006844 100644 --- a/pom.xml +++ b/pom.xml @@ -8,23 +8,12 @@ neo2rdf ${revision} - - - release - - ${version} - - - - 17 17 - - ${git.branch} - 1.0.0 + - ${version}-${sha1}${changelist}-SNAPSHOT + 1.0.0${sha1}${changelist} 1.1.0 UTF-8 5.18.1 @@ -67,51 +56,6 @@ license-maven-plugin 2.4.0 - - - io.github.git-commit-id - git-commit-id-maven-plugin - 7.0.0 - - - get-the-git-infos - - revision - - initialize - - - - true - ${project.build.directory}/git.properties - - true - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - ^git.branch - - full - - - git.branch - ^([^\/]*)\/([^\/]*)$ - $1-$2 - true - - - BEFORE - UPPER_CASE - - - AFTER - LOWER_CASE - - - - - - org.apache.maven.plugins maven-surefire-plugin