-
Notifications
You must be signed in to change notification settings - Fork 21
114 lines (99 loc) · 5.2 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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/