-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (92 loc) · 4.34 KB
/
ci.yaml
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
name: ci-lib
on:
push:
branches:
- "**"
env:
BUILD_FAILURE_SLACK_CHANNEL: "#europris-dev-info"
defaults:
run:
# NOTE: A bit stricter than the default bash options used by GitHub Actions
# (bash --noprofile --norc -e -o pipefail {0})
shell: bash --noprofile --norc -euo pipefail {0}
# NOTE: Set concurrency for the current workflow to 1
concurrency: ci-${{ github.ref }}-${{ github.workflow }}
jobs:
build-and-release:
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
deployments: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: "zulu"
java-version: "17.0.9"
java-package: "jdk"
- uses: capralifecycle/actions-lib/check-runtime-dependencies@f3dcdbe2cd85725311b4ff5ff8dde9dfaf4f3111 # v1.5.4
- name: cache mvn
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: release preparation
id: prep
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
major_version="$(sed -n "s/^.*<major-version>\([0-9]\{1,\}\)<\/major-version>.*$/\1/p" pom.xml)"
echo "$major_version" | grep -q "^[0-9]\{1,\}$" || {
echo "ERROR: Failed to extract <major-version> from pom.xml"
exit 1
}
echo "major-version=$major_version" >> "$GITHUB_OUTPUT"
- uses: capralifecycle/actions-lib/generate-tag@f3dcdbe2cd85725311b4ff5ff8dde9dfaf4f3111 # v1.5.4
id: tag
with:
tag-prefix: "${{ steps.prep.outputs.major-version }}"
tag-type: "punctuated-timestamp-tag"
- name: conditional release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONDITIONAL_RELEASE: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
TAG: "${{ steps.tag.outputs.tag }}"
SONARCLOUD_TOKEN: ${{ secrets.SHARED_SONAR_TOKEN }}
GIT_COMMIT_SHA: ${{ github.sha }}
RUN_NUMBER: ${{ github.run_number }}
run: |
if [ "$CONDITIONAL_RELEASE" = "true" ]; then
echo "Releasing library with tag '$TAG'"
mvn -B source:jar deploy scm:tag -Drevision="$TAG" -Dtag="$TAG" \
org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseDeps
else
mvn -B dependency:resolve -U verify
fi
- name: show errors
if: ${{ failure() }}
env:
FAILS_FILE: ${{ runner.temp }}/fails.txt
run: |
echo '## Build failure ' >> $GITHUB_STEP_SUMMARY
{ find . -type f -path '*target/surefire-reports/*.txt' -exec grep -l -E '(Failures: [^0]|Errors: [^0])' {} >> "${FAILS_FILE}" \; || :; }
{ find . -type f -path '*target/failsafe-reports/*.txt' -exec grep -l -E '(Failures: [^0]|Errors: [^0])' {} >> "${FAILS_FILE}" \; || :; }
while IFS="" read -r errorFile || [ -n "$errorFile" ]; do
echo "**${errorFile}** " >> $GITHUB_STEP_SUMMARY
echo '```text' >> $GITHUB_STEP_SUMMARY
cat "${errorFile}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '---' >> $GITHUB_STEP_SUMMARY
done < "${FAILS_FILE}"
- uses: capralifecycle/actions-lib/slack-notify@f3dcdbe2cd85725311b4ff5ff8dde9dfaf4f3111 # v1.5.4
# NOTE: We only want to be notified about failures on the default branch
if: ${{ failure() && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
with:
bot-token: ${{ secrets.SHARED_SLACK_BOT_TOKEN }}
channel: ${{ env.BUILD_FAILURE_SLACK_CHANNEL }}
- uses: capralifecycle/actions-lib/configure-github-deployment@f3dcdbe2cd85725311b4ff5ff8dde9dfaf4f3111 # v1.5.4
# NOTE: Create GitHub deployment on default branch regardless of job status
if: ${{ always() && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}