|
| 1 | +name: Build and upload artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + BUILD_COMMAND: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + LANGUAGE: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + ARTIFACT_ARCHIVE_BASE_NAME: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + ARTIFACT_NAME: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-upload-artifacts: |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + architecture: [ amd64, arm64 ] |
| 24 | + env: |
| 25 | + BUILD_COMMAND: ${{ inputs.BUILD_COMMAND }} |
| 26 | + LANGUAGE: ${{ inputs.LANGUAGE }} |
| 27 | + ARTIFACT_ARCHIVE_BASE_NAME: ${{ inputs.ARTIFACT_ARCHIVE_BASE_NAME }} |
| 28 | + ARTIFACT_NAME: ${{ inputs.ARTIFACT_NAME }} |
| 29 | + ARCHITECTURE: ${{ matrix.architecture }} |
| 30 | + GOARCH: ${{ matrix.architecture }} |
| 31 | + name: Build and upload artifacts |
| 32 | + runs-on: ubuntu-22.04 |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v3 |
| 35 | + with: |
| 36 | + submodules: true |
| 37 | + - uses: actions/setup-go@v4 |
| 38 | + with: |
| 39 | + go-version: '^1.19.3' |
| 40 | + - uses: actions/setup-java@v3 |
| 41 | + if: env.LANGUAGE == 'java' |
| 42 | + with: |
| 43 | + distribution: adopt |
| 44 | + java-version: '11' |
| 45 | + - name: Cache (Java) |
| 46 | + if: env.LANGUAGE == 'java' |
| 47 | + uses: actions/cache@v3 |
| 48 | + with: |
| 49 | + path: | |
| 50 | + ~/go/pkg/mod |
| 51 | + ~/.gradle/caches |
| 52 | + ~/.gradle/wrapper |
| 53 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-go-${{ hashFiles('**/go.sum') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-gradle- |
| 56 | + - uses: actions/setup-node@v3 |
| 57 | + if: env.LANGUAGE == 'nodejs' |
| 58 | + with: |
| 59 | + node-version: '14' |
| 60 | + - name: Cache (NodeJS) |
| 61 | + if: env.LANGUAGE == 'nodejs' |
| 62 | + uses: actions/cache@v3 |
| 63 | + with: |
| 64 | + path: | |
| 65 | + ~/go/pkg/mod |
| 66 | + ~/.npm |
| 67 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-go-${{ hashFiles('**/go.sum') }} |
| 68 | + restore-keys: | |
| 69 | + ${{ runner.os }}-node- |
| 70 | + - uses: actions/setup-python@v4 |
| 71 | + if: env.LANGUAGE == 'python' |
| 72 | + with: |
| 73 | + python-version: '3.9' |
| 74 | + - name: Cache (Python) |
| 75 | + if: env.LANGUAGE == 'python' |
| 76 | + uses: actions/cache@v3 |
| 77 | + with: |
| 78 | + path: | |
| 79 | + ~/go/pkg/mod |
| 80 | + ~/.cache/pip |
| 81 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-go-${{ hashFiles('**/go.sum') }} |
| 82 | + restore-keys: | |
| 83 | + ${{ runner.os }}-pip- |
| 84 | + - name: Build artifacts - ${{ matrix.architecture }} |
| 85 | + run: ${{ env.BUILD_COMMAND }} |
| 86 | + - name: Upload artifacts - java |
| 87 | + if: env.LANGUAGE == 'java' && success() |
| 88 | + uses: actions/upload-artifact@v3 |
| 89 | + with: |
| 90 | + name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts |
| 91 | + path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip |
| 92 | + if-no-files-found: error |
| 93 | + - name: Rename sample-app java artifact |
| 94 | + if: env.LANGUAGE == 'java' && success() |
| 95 | + run: | |
| 96 | + mv opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/aws-sdk-all.jar \ |
| 97 | + opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/java-sample-app.jar |
| 98 | + - name: Upload artifacts - java sample-app |
| 99 | + if: env.LANGUAGE == 'java' && success() |
| 100 | + uses: actions/upload-artifact@v3 |
| 101 | + with: |
| 102 | + name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts |
| 103 | + path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/java-sample-app.jar |
| 104 | + if-no-files-found: error |
| 105 | + - name: Upload artifacts - nodejs |
| 106 | + if: env.LANGUAGE == 'nodejs' && success() |
| 107 | + uses: actions/upload-artifact@v3 |
| 108 | + with: |
| 109 | + name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts |
| 110 | + path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip |
| 111 | + if-no-files-found: error |
| 112 | + - name: Rename sample-app nodejs artifact |
| 113 | + if: env.LANGUAGE == 'nodejs' && success() |
| 114 | + run: | |
| 115 | + mv opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/function.zip \ |
| 116 | + opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/nodejs-sample-app.zip |
| 117 | + - name: Upload artifacts - nodejs sample-app |
| 118 | + if: env.LANGUAGE == 'nodejs' && success() |
| 119 | + uses: actions/upload-artifact@v3 |
| 120 | + with: |
| 121 | + name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts |
| 122 | + path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/nodejs-sample-app.zip |
| 123 | + if-no-files-found: error |
| 124 | + - name: Upload artifacts - python layer |
| 125 | + if: env.LANGUAGE == 'python' && success() |
| 126 | + uses: actions/upload-artifact@v3 |
| 127 | + with: |
| 128 | + name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts |
| 129 | + path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip |
| 130 | + if-no-files-found: error |
| 131 | + - name: Rename sample-app python artifact |
| 132 | + if: env.LANGUAGE == 'python' && success() |
| 133 | + run: | |
| 134 | + mv opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/function.zip \ |
| 135 | + opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/python-sample-app.zip |
| 136 | + - name: Upload artifacts - python sample-app |
| 137 | + if: env.LANGUAGE == 'python' && success() |
| 138 | + uses: actions/upload-artifact@v3 |
| 139 | + with: |
| 140 | + name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts |
| 141 | + path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/python-sample-app.zip |
| 142 | + if-no-files-found: error |
0 commit comments