11name : Java CI
22
3- on :
4- push :
5- pull_request :
6- workflow_dispatch :
7- inputs :
8- deploy :
9- description : ' Deploy to Maven Central'
10- type : boolean
11- default : false
12- luceeVersions :
13- description : ' JSON array of Lucee versions to test'
14- required : false
15- default : ' [ "6/snapshot/light", "7.0/snapshot/light", "7.1/snapshot/light" ]'
3+ on : [push, pull_request, workflow_dispatch]
164
175jobs :
18- build :
6+ setup :
197 runs-on : ubuntu-latest
20- timeout-minutes : 15
218 outputs :
229 version : ${{ steps.extract-version.outputs.VERSION }}
2310 steps :
24- - uses : actions/checkout@v6
11+ - name : Checkout repository
12+ uses : actions/checkout@v4
2513
2614 - name : Set up JDK 11
27- uses : actions/setup-java@v5
15+ uses : actions/setup-java@v4
2816 with :
29- java-version : ' 11'
3017 distribution : ' temurin'
18+ java-version : ' 11'
3119
3220 - name : Cache Maven packages
33- uses : actions/cache@v5
21+ uses : actions/cache@v4
3422 with :
35- path : ~/.m2/repository
36- key : maven-${{ hashFiles('pom.xml') }}
37- restore-keys : maven-
23+ path : ~/.m2
24+ key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
25+ restore-keys : |
26+ ${{ runner.os }}-maven-
3827
3928 - name : Extract version number
4029 id : extract-version
4130 run : |
4231 VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
4332 echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
4433
45- - name : Build extension
46- run : mvn -B -e clean package
47-
48- - name : Upload Artifact
49- uses : actions/upload-artifact@v7
34+ - name : Cache Lucee files
35+ uses : actions/cache@v4
5036 with :
51- name : ehcache-lex
52- path : target/*.lex
37+ path : ~/work/_actions/lucee/script-runner/main/lucee-download-cache
38+ key : lucee-downloads
39+
40+ - name : Import GPG key
41+ run : |
42+ echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
43+ env :
44+ GPG_PRIVATE_KEY : ${{ secrets.GPG_PRIVATE_KEY }}
5345
54- test :
46+ build-and- test :
5547 runs-on : ubuntu-latest
5648 timeout-minutes : 30
57- needs : build
49+ needs : setup
50+ env :
51+ LUCEE_TEST_VERSIONS : ${{ vars.LUCEE_TEST_VERSIONS }}
5852 strategy :
5953 fail-fast : false
6054 matrix :
61- lucee : ${{ fromJSON(inputs.luceeVersions || '["6/snapshot/light", "7.0/snapshot/light", "7.1/snapshot/light"]' ) }}
55+ lucee : ${{ fromJSON(vars.LUCEE_TEST_VERSIONS ) }}
6256 steps :
63- - uses : actions/checkout@v6
57+ - uses : actions/checkout@v4
6458
65- - name : Cache Lucee files
66- uses : actions/cache@v5
59+ - name : Set up JDK 11
60+ uses : actions/setup-java@v4
6761 with :
68- path : ~/work/_actions/lucee/script-runner/main/lucee-download-cache
69- key : lucee-downloads
62+ java-version : ' 11 '
63+ distribution : ' temurin '
7064
71- - name : Download extension artifact
72- uses : actions/download-artifact@v8
65+ - name : Cache Maven packages
66+ uses : actions/cache@v4
7367 with :
74- name : ehcache-lex
75- path : target
68+ path : ~/.m2
69+ key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
70+ restore-keys : |
71+ ${{ runner.os }}-maven-
72+
73+ - name : Build and Install with Maven (for testing only)
74+ env :
75+ MAVEN_USERNAME : ${{ secrets.MAVEN_USERNAME }}
76+ MAVEN_PASSWORD : ${{ secrets.MAVEN_PASSWORD }}
77+ GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
78+ run : |
79+ echo "------- Maven Install (to create a local test build) -------";
80+ mvn -B -e -f pom.xml clean install -Dgoal=install
81+
82+ - name : Upload Artifact
83+ uses : actions/upload-artifact@v4
84+ with :
85+ name : ehcache-lex-${{ matrix.lucee.version }}
86+ path : target/*.lex
7687
7788 - name : Set up Postgres
7889 run : |
@@ -83,17 +94,19 @@ jobs:
8394 sudo -u postgres psql -c 'grant all on schema public to lucee;' -d lucee
8495
8596 - name : Checkout Lucee
86- uses : actions/checkout@v6
97+ uses : actions/checkout@v4
8798 with :
8899 repository : lucee/lucee
89100 path : lucee
101+ ref : ${{ matrix.lucee.branch }}
90102
91103 - name : Run Lucee Test Suite
92104 uses : lucee/script-runner@main
93105 with :
94106 webroot : ${{ github.workspace }}/lucee/test
95107 execute : /bootstrap-tests.cfm
96- luceeVersion : ${{ matrix.lucee }}
108+ luceeVersion : ${{ matrix.lucee.version }}
109+ luceeVersionQuery : ${{ matrix.lucee.query }}
97110 extensionDir : ${{ github.workspace }}/target
98111 env :
99112 testLabels : ehcache
@@ -107,42 +120,55 @@ jobs:
107120
108121 deploy :
109122 runs-on : ubuntu-latest
110- timeout-minutes : 15
111- needs : [build, test]
112- if : github.event_name == 'workflow_dispatch' && inputs.deploy
123+ needs : [setup, build-and-test]
124+ if : always() && needs.build-and-test.result == 'success'
113125 steps :
114- - uses : actions/checkout@v6
126+ - name : Checkout repository
127+ uses : actions/checkout@v4
115128
116129 - name : Set up JDK 11
117- uses : actions/setup-java@v5
130+ uses : actions/setup-java@v4
118131 with :
119132 distribution : ' temurin'
120133 java-version : ' 11'
121134
122135 - name : Cache Maven packages
123- uses : actions/cache@v5
136+ uses : actions/cache@v4
124137 with :
125- path : ~/.m2/repository
126- key : maven-${{ hashFiles('pom.xml') }}
127- restore-keys : maven-
138+ path : ~/.m2
139+ key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
140+ restore-keys : |
141+ ${{ runner.os }}-maven-
128142
129143 - name : Import GPG key
130144 run : |
131145 echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
132146 env :
133147 GPG_PRIVATE_KEY : ${{ secrets.GPG_PRIVATE_KEY }}
134148
149+ - name : Debug env
150+ env :
151+ MAVEN_USERNAME : ${{ secrets.MAVEN_USERNAME }}
152+ run : |
153+ if [[ -z "${MAVEN_USERNAME}" ]]; then echo "MAVEN_USERNAME is empty"; exit 1; fi
154+ echo "::add-mask::${MAVEN_USERNAME}"
155+ echo "MAVEN_USERNAME (masked): ${MAVEN_USERNAME}"
156+ echo "MAVEN_USERNAME length: ${#MAVEN_USERNAME}"
157+ printf "MAVEN_USERNAME sha256: %s\n" "$(printf %s "$MAVEN_USERNAME" | sha256sum | cut -d' ' -f1)"
158+
135159 - name : Build and Deploy with Maven
136160 env :
137- VERSION : ${{ needs.build.outputs.version }}
138161 MAVEN_USERNAME : ${{ secrets.MAVEN_USERNAME }}
139162 MAVEN_PASSWORD : ${{ secrets.MAVEN_PASSWORD }}
140163 GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
141164 run : |
142- if [[ "$VERSION" == *-SNAPSHOT ]]; then
143- echo "------- Maven Deploy snapshot -------";
144- mvn -B -e clean deploy --settings maven-settings.xml
165+ if [[ "${{ needs.setup.outputs.version }}" == *-SNAPSHOT ]]; then
166+ echo "------- Maven Deploy snapshot on ${{ github.event_name }} -------";
167+ mvn -B -e -f pom.xml clean deploy -Dgoal=deploy --settings maven-settings.xml
168+ elif [[ "${{ needs.setup.outputs.version }}" == *-ALPHA ]]; then
169+ echo "------- Maven Install alpha on ${{ github.event_name }} -------";
170+ mvn -B -e -f pom.xml clean install -Dgoal=install --settings maven-settings.xml
145171 else
146- echo "------- Maven Deploy release -------";
147- mvn -B -e clean deploy -DperformRelease=true --settings maven-settings.xml
148- fi
172+ echo "------- Maven Deploy release on ${{ github.event_name }} -------";
173+ mvn -B -e -f pom.xml clean deploy -Dgoal= deploy -DperformRelease=true --settings maven-settings.xml
174+ fi
0 commit comments