-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (99 loc) · 3.61 KB
/
test-current-branch.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
name: Test current branch
on:
push:
secrets:
USER:
required: true
DEPLOY_GITHUB_TOKEN:
required: true
workflow_call:
secrets:
USER:
required: true
DEPLOY_GITHUB_TOKEN:
required: true
workflow_dispatch:
secrets:
USER:
required: true
DEPLOY_GITHUB_TOKEN:
required: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/*pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run action (non-branch version - should change automatically)
id: run-action-non-branch-version
uses: maven-flow/manage-versions@main
env:
USER: ${{ secrets.USER }}
TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
with:
enforce-branch-version: true
maven-args: "-P github -s ${GITHUB_WORKSPACE}/.github/workflows/maven-settings.xml"
pom-file: "non-branch-version-pom.xml"
- name: Assert version changed
run: .github/workflows/assert-project-version.sh non-branch-version-pom.xml 1.1.0-rc.0-bugfix-BUG-458-SNAPSHOT
- name: Assert output parameters
run: |
if [[ "${{ steps.run-action-non-branch-version.outputs.changes-made }}" = "true" ]]; then
echo "Output changes-made has correct value."
else
echo "ERROR: Output changes-made has incorrect value."
exit 1
fi
- name: Run action (branch version)
id: run-action-branch-version
uses: maven-flow/manage-versions@main
env:
USER: ${{ secrets.USER }}
TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
with:
enforce-branch-version: true
maven-args: "-P github -s ${GITHUB_WORKSPACE}/.github/workflows/maven-settings.xml"
pom-file: "branch-version-pom.xml"
- name: Assert version unchanged
run: .github/workflows/assert-project-version.sh branch-version-pom.xml 1.1.0-rc.0-BUG-458-SNAPSHOT
- name: Assert dependency version unchanged
run: .github/workflows/assert-dependency-version.sh branch-version-pom.xml com.jardoapps.maven-flow dummy-dependency 1.1.0-rc.0-BUG-458-SNAPSHOT
- name: Assert output parameters
run: |
if [[ "${{ steps.run-action-branch-version.outputs.changes-made }}" = "false" ]]; then
echo "Output changes-made has correct value."
else
echo "ERROR: Output changes-made has incorrect value."
exit 1
fi
- name: Revert changes
run: git restore .
- name: Run action (non-branch version, do not enforce)
id: run-action-non-branch-version-do-not-enforce
uses: maven-flow/manage-versions@main
env:
USER: ${{ secrets.USER }}
TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
with:
enforce-branch-version: false
maven-args: "-P github -s ${GITHUB_WORKSPACE}/.github/workflows/maven-settings.xml"
pom-file: "non-branch-version-pom.xml"
- name: Assert version unchanged
run: .github/workflows/assert-project-version.sh non-branch-version-pom.xml 1.1.0-rc.0-SNAPSHOT
- name: Assert output parameters
run: |
if [[ "${{ steps.run-action-non-branch-version-do-not-enforce.outputs.changes-made }}" = "false" ]]; then
echo "Output changes-made has correct value."
else
echo "ERROR: Output changes-made has incorrect value."
exit 1
fi