|
| 1 | +name: 'install-mvnd' |
| 2 | +description: 'Install the Maven Daemon' |
| 3 | +inputs: |
| 4 | + version: |
| 5 | + description: 'The version of the Maven Daemon to install' |
| 6 | + required: true |
| 7 | + default: '0.9.0' |
| 8 | + file-version-suffix: |
| 9 | + description: 'A suffix to append to the version of the download file of Maven Daemon to install' |
| 10 | + required: false |
| 11 | + default: '' |
| 12 | + install-path: |
| 13 | + description: 'The folder in which Maven Daemon will be installed as a sub-folder' |
| 14 | + required: true |
| 15 | + default: '/tmp' |
| 16 | + cache: |
| 17 | + description: 'Set to true to cache Maven Daemon artifacts per-platform-architecture' |
| 18 | + required: true |
| 19 | + default: 'true' |
| 20 | + mvnd-connect-timeout: |
| 21 | + description: 'The timeout (as a duration, e.g. `90 seconds`) for connecting to the Maven Daemon' |
| 22 | + required: true |
| 23 | + default: '90 seconds' |
| 24 | +outputs: |
| 25 | + mvnd-dir: |
| 26 | + description: "The directory where the command mvnd is located" |
| 27 | + value: ${{ steps.mvnd-location.outputs.mvnd-dir }} |
| 28 | +runs: |
| 29 | + using: "composite" |
| 30 | + steps: |
| 31 | + - name: Determine mvnd platform and architecture |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 35 | + MVND_PLATFORM="linux" |
| 36 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 37 | + MVND_PLATFORM="darwin" |
| 38 | + elif [ "$RUNNER_OS" == "Windows" ]; then |
| 39 | + MVND_PLATFORM="windows" |
| 40 | + else |
| 41 | + "echo Unknown platform: $RUNNER_OS" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + MVND_ARCHITECTURE="amd64" |
| 45 | + echo "MVND_PLATFORM=${MVND_PLATFORM}" >> $GITHUB_ENV |
| 46 | + echo "MVND_ARCHITECTURE=${MVND_ARCHITECTURE}" >> $GITHUB_ENV |
| 47 | + echo "MVND_NAME=maven-mvnd-${{ inputs.version }}${{ inputs.file-version-suffix }}-${MVND_PLATFORM}-${MVND_ARCHITECTURE}" >> $GITHUB_ENV |
| 48 | + - name: Cache mvnd |
| 49 | + if: inputs.cache == 'true' |
| 50 | + id: cache-mvnd |
| 51 | + uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: | |
| 54 | + ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip |
| 55 | + ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip.sha256 |
| 56 | + ${{ inputs.install-path }}/${{ env.MVND_NAME }} |
| 57 | + key: setup-${{ env.MVND_NAME }} |
| 58 | + - name: Download mvnd |
| 59 | + if: steps.cache-mvnd.outputs.cache-hit != 'true' |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + curl -fsSL -o ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/${{ env.MVND_NAME }}.zip |
| 63 | + curl -fsSL -o ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip.sha256 https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/${{ env.MVND_NAME }}.zip.sha256 |
| 64 | + - name: Install sha256sum (macOS) |
| 65 | + if: ${{ runner.os == 'macOS' }} |
| 66 | + shell: bash |
| 67 | + run: brew install coreutils |
| 68 | + - name: Verify mvnd sha256 checksum |
| 69 | + shell: bash |
| 70 | + run: echo "$(cat ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip.sha256) ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip" | sha256sum --check |
| 71 | + - name: Unzip mvnd |
| 72 | + if: steps.cache-mvnd.outputs.cache-hit != 'true' |
| 73 | + shell: bash |
| 74 | + run: unzip ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip -d ${{ inputs.install-path }}/ |
| 75 | + - name: Show Maven Daemon version |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + ${{ inputs.install-path }}/${{ env.MVND_NAME }}/bin/mvnd -D'mvnd.connectTimeout=${{ inputs.mvnd-connect-timeout }}' --version |
| 79 | + ${{ inputs.install-path }}/${{ env.MVND_NAME }}/bin/mvnd -D'mvnd.connectTimeout=${{ inputs.mvnd-connect-timeout }}' --status |
| 80 | + - name: Set mvnd-dir |
| 81 | + id: mvnd-location |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + MVND_BIN_DIR="${{ inputs.install-path }}/${{ env.MVND_NAME }}/bin" |
| 85 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 86 | + MVND_BIN_DIR="$(cygpath --absolute --long-name --windows $MVND_BIN_DIR)" |
| 87 | + fi |
| 88 | + echo "MVND_BIN_DIR=${MVND_BIN_DIR}" >> $GITHUB_ENV |
| 89 | + echo "mvnd-dir=${MVND_BIN_DIR}" >> $GITHUB_OUTPUT |
0 commit comments