[skip bump] version bump #1820
This file contains 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: Build Stream Services | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- 'support/**' | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
main: | |
if: "!contains(github.event.head_commit.message, '[skip bump]') && !contains(github.event.head_commit.message, 'nobump/')" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonar analysis | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: maven | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Configure Maven | |
uses: whelk-io/maven-settings-xml-action@v4 | |
with: | |
repositories: '[{ "id": "backbase", "url": "https://repo.backbase.com/repo" }]' | |
plugin_repositories: '[{ "id": "backbase-plugins", "url": "https://repo.backbase.com/repo" }]' | |
servers: '[{ "id": "backbase", "username": "${{ secrets.REPO_USERNAME }}", "password": "${{ secrets.REPO_PASSWORD }}" },{ "id": "backbase-plugins", "username": "${{ secrets.REPO_USERNAME }}", "password": "${{ secrets.REPO_PASSWORD }}" }]' | |
- name: Get version from POM | |
run: | | |
VERSION=$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout) | |
VERSION_PARTS=($(echo $VERSION | tr "." "\n")) | |
echo "MAJOR=${VERSION_PARTS[0]}" >> $GITHUB_ENV | |
echo "MINOR=${VERSION_PARTS[1]}" >> $GITHUB_ENV | |
echo "PATCH=${VERSION_PARTS[2]}" >> $GITHUB_ENV | |
echo "DOCKER_TAG_VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Setup release version | |
if: contains(github.ref, 'master') | |
run: | | |
NEW_VERSION="$((MAJOR)).$((MINOR+1)).0" | |
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
- name: Setup release version from a snapshot | |
if: "contains(github.ref, 'master') && contains(env.PATCH, 'SNAPSHOT')" | |
run: | | |
NEW_VERSION="${MAJOR}.${MINOR}.$(echo $PATCH | awk 'BEGIN { FS = "-" } ; { print $1 }')" | |
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
- name: Setup patch version | |
if: "(contains(github.ref, 'master') || contains(github.ref, 'support/')) && contains(github.event.head_commit.message, 'hotfix/')" | |
run: | | |
NEW_VERSION="$((MAJOR)).$((MINOR)).$((PATCH+1))" | |
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
- name: Setup PR version | |
if: contains(github.ref, '/pull/') | |
run: | | |
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}-PR-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" | |
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
- name: Setup docker tag version | |
if: "env.NEW_VERSION != null" | |
run: | | |
echo "DOCKER_TAG_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
- name: Setup snapshot docker tag with execution number | |
if: "env.NEW_VERSION == null && contains(env.PATCH, 'SNAPSHOT')" | |
run: | | |
DOCKER_TAG_VERSION="${MAJOR}.${MINOR}.$(echo $PATCH | awk 'BEGIN { FS = "-" } ; { print $1 }')-rc${GITHUB_RUN_NUMBER}" | |
echo "DOCKER_TAG_VERSION=${DOCKER_TAG_VERSION}" >> $GITHUB_ENV | |
- name: Update POM Version | |
if: env.NEW_VERSION != null | |
run: | | |
echo "New version is: $NEW_VERSION" | |
mvn -B versions:set versions:update-child-modules -DnewVersion=${NEW_VERSION} -DprocessAllModules -DgenerateBackupPoms=false | |
- name: Build Stream Services | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar | |
- name: Commit files | |
if: "contains(github.ref, 'master') || contains(github.ref, 'support/')" | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "backbaseoss" | |
git commit -m "[skip bump] version bump" -a | |
git tag -a $NEW_VERSION -m "[version bump]" | |
- name: Push changes | |
if: "contains(github.ref, 'master') || contains(github.ref, 'support/')" | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.STREAM_BOT_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Upload to Repo | |
if: "contains(github.ref, 'master') || contains(github.ref, 'support/') || contains(github.ref, 'develop')" # In case of develop branch it will upload the snapshot version | |
run: mvn -B clean deploy -Pdocker-image,no-latest-tag -Dmaven.test.skip=true -Ddocker.default.tag=${{ env.DOCKER_TAG_VERSION }} -Ddocker.repo.url=repo.backbase.com -Ddocker.repo.project=backbase-stream-images -Djib.to.auth.username=${{ secrets.REPO_USERNAME }} -Djib.to.auth.password=${{ secrets.REPO_PASSWORD }} -DaltDeploymentRepository=backbase::default::https://repo.backbase.com/backbase-stream-releases/ |