|
| 1 | +name: Java CI |
| 2 | + |
| 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: '[{"version":"","query":"7.0/stable/light"},{"version":"","query":"7.1/snapshot/light"}]' |
| 16 | + |
| 17 | +jobs: |
| 18 | + setup: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + version: ${{ steps.extract-version.outputs.VERSION }} |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up JDK 11 |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + java-version: '11' |
| 30 | + distribution: 'temurin' |
| 31 | + |
| 32 | + - name: Cache Maven packages |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: ~/.m2 |
| 36 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-maven- |
| 39 | +
|
| 40 | + - name: Extract version number |
| 41 | + id: extract-version |
| 42 | + run: | |
| 43 | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 44 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 45 | +
|
| 46 | + - name: Cache Lucee files |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache |
| 50 | + key: lucee-downloads |
| 51 | + |
| 52 | + build-and-test: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + needs: setup |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + lucee: ${{ fromJSON(inputs.luceeVersions || vars.LUCEE_TEST_VERSIONS_PLUS || '[{"version":"","query":"7.0/stable/light"},{"version":"","query":"7.1/snapshot/light"}]') }} |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Set up JDK 11 |
| 63 | + uses: actions/setup-java@v4 |
| 64 | + with: |
| 65 | + java-version: '11' |
| 66 | + distribution: 'adopt' |
| 67 | + |
| 68 | + - name: Build and Install with Maven (for testing only) |
| 69 | + env: |
| 70 | + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} |
| 71 | + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} |
| 72 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 73 | + run: | |
| 74 | + echo "------- Maven Install (to create a local test build) -------"; |
| 75 | + mvn -B -e -f pom.xml clean install -Dgoal=install |
| 76 | +
|
| 77 | + - name: Upload Artifact |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: crypto-lex-${{ matrix.lucee.version }} |
| 81 | + path: target/*.lex |
| 82 | + |
| 83 | + - name: Checkout Lucee |
| 84 | + uses: actions/checkout@v4 |
| 85 | + with: |
| 86 | + repository: lucee/lucee |
| 87 | + path: lucee |
| 88 | + ref: ${{ matrix.lucee.branch }} |
| 89 | + |
| 90 | + - name: Run Lucee Test Suite |
| 91 | + uses: lucee/script-runner@main |
| 92 | + with: |
| 93 | + webroot: ${{ github.workspace }}/lucee/test |
| 94 | + execute: /bootstrap-tests.cfm |
| 95 | + luceeVersion: ${{ matrix.lucee.version }} |
| 96 | + luceeVersionQuery: ${{ matrix.lucee.query }} |
| 97 | + extensionDir: ${{ github.workspace }}/target |
| 98 | + env: |
| 99 | + testLabels: crypto |
| 100 | + testAdditional: ${{ github.workspace }}/tests |
| 101 | + LUCEE_ADMIN_PASSWORD: admin |
| 102 | + |
| 103 | + deploy: |
| 104 | + runs-on: ubuntu-latest |
| 105 | + needs: [setup, build-and-test] |
| 106 | + if: github.event_name == 'workflow_dispatch' && inputs.deploy && needs.build-and-test.result == 'success' |
| 107 | + steps: |
| 108 | + - name: Checkout repository |
| 109 | + uses: actions/checkout@v4 |
| 110 | + |
| 111 | + - name: Set up JDK 11 |
| 112 | + uses: actions/setup-java@v4 |
| 113 | + with: |
| 114 | + distribution: 'temurin' |
| 115 | + java-version: '11' |
| 116 | + |
| 117 | + - name: Cache Maven packages |
| 118 | + uses: actions/cache@v4 |
| 119 | + with: |
| 120 | + path: ~/.m2 |
| 121 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 122 | + restore-keys: | |
| 123 | + ${{ runner.os }}-maven- |
| 124 | +
|
| 125 | + - name: Import GPG key |
| 126 | + run: | |
| 127 | + echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import |
| 128 | + env: |
| 129 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 130 | + |
| 131 | + - name: Build and Deploy with Maven |
| 132 | + env: |
| 133 | + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} |
| 134 | + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} |
| 135 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 136 | + run: | |
| 137 | + if [[ "${{ needs.setup.outputs.version }}" == *-SNAPSHOT ]]; then |
| 138 | + echo "------- Maven Deploy snapshot on ${{ github.event_name }} -------"; |
| 139 | + mvn -B -e -f pom.xml clean deploy -Dgoal=deploy --settings maven-settings.xml |
| 140 | + elif [[ "${{ needs.setup.outputs.version }}" == *-ALPHA ]]; then |
| 141 | + echo "------- Maven Install alpha on ${{ github.event_name }} -------"; |
| 142 | + mvn -B -e -f pom.xml clean install -Dgoal=install --settings maven-settings.xml |
| 143 | + else |
| 144 | + echo "------- Maven Deploy release on ${{ github.event_name }} -------"; |
| 145 | + mvn -B -e -f pom.xml clean deploy -Dgoal=deploy -DperformRelease=true --settings maven-settings.xml |
| 146 | + fi |
0 commit comments