-
Notifications
You must be signed in to change notification settings - Fork 5
121 lines (115 loc) · 4.28 KB
/
build-and-release-maven.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
115
116
117
118
119
120
121
name: Build and Release Maven project
on:
workflow_call:
inputs:
java-version:
description: the desired Java version
type: string
required: false
default: "17"
java-distribution:
description: the desired Java distribution
type: string
required: false
default: "temurin"
skip-tests:
description: skips the tests during the Build phase if set to 'true'
type: boolean
required: false
default: false
build-args:
description: additional Maven build arguments
type: string
required: false
default: ''
auto-release:
description: release automatically or only when the [release] commit trigger is present
type: boolean
required: false
default: true
release-branches:
description: regex defining branches that are valid for the release process
type: string
required: false
default: '' # defaults to github.event.repository.default_branch
release-args:
description: additional Maven release arguments
type: string
required: false
default: ''
extra-maven-opts:
description: additional Maven build options
type: string
required: false
secrets:
BOT_GITHUB_USERNAME:
required: false
BOT_GITHUB_EMAIL:
required: false
BOT_GITHUB_TOKEN:
required: false
NEXUS_USERNAME:
required: true
NEXUS_PASSWORD:
required: true
env:
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
with:
java-version: ${{ inputs.java-version }}
java-distribution: ${{ inputs.java-distribution }}
- name: "Build"
if: ${{ inputs.skip-tests }}
run: mvn -B -V install -DskipTests ${{ inputs.build-args }}
- name: "Build and Test"
if: ${{ !inputs.skip-tests }}
run: mvn -B -V install ${{ inputs.build-args }}
compute_release_conditions:
name: "Compute Release conditions"
runs-on: ubuntu-latest
needs: build
steps:
- name: Compute Release conditions
id: compute
run: |
SHOULD_RELEASE=false
RELEASE_BRANCHES="${{ inputs.release-branches }}"
if [[ -z "$RELEASE_BRANCHES" ]]; then
RELEASE_BRANCHES="^${{ github.event.repository.default_branch }}$"
fi
if [[ ! "${{ github.event.head_commit.message }}" =~ \[no-release\] ]] && [[ "${{ github.ref_name }}" =~ $RELEASE_BRANCHES ]]; then
if [[ "${{ inputs.auto-release }}" == "true" ]] || [[ "${{ github.event.head_commit.message }}" =~ \[release\] ]]; then
SHOULD_RELEASE=true
fi
fi
echo "should_release=${SHOULD_RELEASE}" >> $GITHUB_OUTPUT
outputs:
should_release: ${{ steps.compute.outputs.should_release }}
release:
name: "Release"
runs-on: ubuntu-latest
needs: compute_release_conditions
if: needs.compute_release_conditions.outputs.should_release == 'true'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
with:
java-version: ${{ inputs.java-version }}
java-distribution: ${{ inputs.java-distribution }}
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
with:
username: ${{ secrets.BOT_GITHUB_USERNAME }}
email: ${{ secrets.BOT_GITHUB_EMAIL }}
- name: "Build"
run: mvn -B -V install -DskipTests ${{ inputs.build-args }}
- name: "Release"
run: mvn -B -DscmCommentPrefix="[maven-release-plugin][skip ci] " -Dusername="${{ secrets.BOT_GITHUB_USERNAME }}" -Dpassword="${{ secrets.BOT_GITHUB_TOKEN }}" -DskipTests -Darguments="-DskipTests ${{ inputs.release-args }}" ${{ inputs.extra-maven-opts }} release:clean release:prepare release:perform