Merge pull request #407 from cap-java/fix_HeapOOMForLargeFile #325
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Main build and snapshot deploy | |
| env: | |
| JAVA_VERSION: '17' | |
| MAVEN_VERSION: '3.6.3' | |
| on: | |
| push: | |
| branches: [ "develop" ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| java-version: [ 17 ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Build | |
| uses: ./.github/actions/build | |
| with: | |
| java-version: ${{ matrix.java-version }} | |
| maven-version: ${{ env.MAVEN_VERSION }} | |
| update-version: | |
| name: Update version | |
| runs-on: ubuntu-latest | |
| needs: [ build ] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Java ${{ env.JAVA_VERSION }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: sapmachine | |
| cache: maven | |
| - name: Set up Maven ${{ env.MAVEN_VERSION }} | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: ${{ env.MAVEN_VERSION }} | |
| - name: Get Revision | |
| id: get-revision | |
| run: | | |
| current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "Current version: $current_version" | |
| echo "REVISION=$current_version" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Check and Update Version | |
| if: github.ref == 'refs/heads/develop' | |
| id: check-and-update-version | |
| run: | | |
| current_version=${{ env.REVISION }} | |
| # Check if the version already contains '-SNAPSHOT' | |
| if [[ $current_version != *-SNAPSHOT ]]; then | |
| echo "Current version does not contain -SNAPSHOT, updating version..." | |
| # Split version into major, minor, and patch parts | |
| IFS='.' read -r major minor patch <<< "$(echo $current_version | tr '-' '.')" | |
| # Increment the patch number | |
| new_patch=$((patch + 1)) | |
| # Form the new version | |
| new_version="${major}.${minor}.${new_patch}-SNAPSHOT" | |
| # Update the <revision> property in pom.xml | |
| sed -i "s|<revision>.*</revision>|<revision>${new_version}</revision>|" pom.xml | |
| echo "Updated version to $new_version" | |
| # Commit the version change | |
| git config --local user.name "github-actions" | |
| git config --local user.email "github-actions@github.com" | |
| git add pom.xml | |
| git commit -m "Increment version to ${new_version}" | |
| git push origin HEAD:develop | |
| else | |
| echo "Current version already contains -SNAPSHOT, no update needed." | |
| fi | |
| # Export the updated or original version | |
| updated_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "UPDATED_VERSION=$updated_version" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Print Updated Version | |
| run: | | |
| echo "Updated version: ${{ env.UPDATED_VERSION }}" | |
| shell: bash | |
| - name: Deploy snapshot | |
| if: ${{ endsWith(env.UPDATED_VERSION, '-SNAPSHOT') }} | |
| run: | | |
| mvn -B -ntp -fae -Dmaven.install.skip=true -Dmaven.test.skip=true -DdeployAtEnd=true -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/cap-java/sdm deploy | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} | |
| shell: bash |