Publish Node.js #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Node.js | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Actually publish or just test?' | |
type: environment | |
required: true | |
default: test | |
jobs: | |
package: | |
runs-on: ubuntu-22.04 | |
if: ${{ github.ref == 'refs/heads/coralogix-nodejs-autoinstrumentation' || inputs.environment == 'test' }} | |
environment: ${{ inputs.environment }} | |
env: | |
OPENTELEMETRY_JS_CONTRIB_PATH: ${{ github.workspace }}/opentelemetry-js-contrib | |
OPENTELEMETRY_JS_PATH: ${{ github.workspace }}/opentelemetry-js | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/checkout@v3 | |
with: | |
path: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }} | |
repository: coralogix/opentelemetry-js-contrib | |
ref: refs/heads/merge-0.39.0 | |
ssh-key: ${{ secrets.OPENTELEMETRY_CI_GITHUB_KEY }} | |
- uses: actions/checkout@v3 | |
with: | |
path: ${{ env.OPENTELEMETRY_JS_PATH }} | |
repository: coralogix/opentelemetry-js | |
ref: refs/heads/merge-0.49.1 | |
ssh-key: ${{ secrets.OPENTELEMETRY_CI_GITHUB_KEY }} | |
- name: Generate version files in opentelemetry-js-contrib | |
working-directory: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }} | |
run: npx [email protected] run version:update # Newer versions have trouble with our lerna.json which contains `useWorkspaces` | |
- name: Prepare opentelemetry-js-contrib | |
working-directory: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }} | |
run: npm install | |
- name: Build opentelemetry-propagator-aws-xray | |
working-directory: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }}/propagators/opentelemetry-propagator-aws-xray | |
run: npm install && npm run compile | |
- name: Build opentelemetry-instrumentation-aws-lambda | |
working-directory: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }}/plugins/node/opentelemetry-instrumentation-aws-lambda | |
run: npm install --ignore-scripts && npm run compile && npm pack --ignore-scripts | |
- name: Build opentelemetry-instrumentation-mongodb | |
working-directory: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }}/plugins/node/opentelemetry-instrumentation-mongodb | |
run: npm install --ignore-scripts && npm run compile && npm pack --ignore-scripts | |
- name: Build opentelemetry-instrumentation-aws-sdk | |
working-directory: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }}/plugins/node/opentelemetry-instrumentation-aws-sdk | |
run: npm install --ignore-scripts && npm run compile && npm pack --ignore-scripts | |
- name: Prepare opentelemetry-js | |
working-directory: ${{ env.OPENTELEMETRY_JS_PATH }} | |
run: npm install | |
- name: Build sdk-logs | |
working-directory: ${{ env.OPENTELEMETRY_JS_PATH }}/experimental/packages/sdk-logs | |
run: npm install && npm run compile | |
- name: Build opentelemetry-instrumentation | |
working-directory: ${{ env.OPENTELEMETRY_JS_PATH }}/experimental/packages/opentelemetry-instrumentation | |
run: npm install && npm run compile && npm pack | |
- name: Build opentelemetry-sdk-trace-base | |
working-directory: ${{ env.OPENTELEMETRY_JS_PATH }}/packages/opentelemetry-sdk-trace-base | |
run: npm install && npm run compile && npm pack | |
- name: Install forked opentelemetry-js/opentelemetry-js-contrib libraries | |
working-directory: ./nodejs/packages/layer | |
run: > | |
npm install | |
${OPENTELEMETRY_JS_CONTRIB_PATH}/plugins/node/opentelemetry-instrumentation-aws-lambda/opentelemetry-instrumentation-aws-lambda-*.tgz | |
${OPENTELEMETRY_JS_CONTRIB_PATH}/plugins/node/opentelemetry-instrumentation-mongodb/opentelemetry-instrumentation-mongodb-*.tgz | |
${OPENTELEMETRY_JS_CONTRIB_PATH}/plugins/node/opentelemetry-instrumentation-aws-sdk/opentelemetry-instrumentation-aws-sdk-*.tgz | |
${OPENTELEMETRY_JS_PATH}/experimental/packages/opentelemetry-instrumentation/opentelemetry-instrumentation-*.tgz | |
${OPENTELEMETRY_JS_PATH}/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-*.tgz | |
- name: Install copyfiles and bestzip # used by `npm run compile` | |
run: npm install -g copyfiles bestzip | |
- name: Build layer | |
working-directory: ./nodejs/packages/layer | |
run: npm install && npm run compile | |
- name: Check layer size | |
env: | |
FILE_PATH: ./nodejs/packages/layer/build/layer.zip | |
MAX_SIZE: 8388608 # 8MB | |
run: ./ci-scripts/check_size.sh | |
- uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ vars.SIGNER_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.SIGNER_AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ vars.SIGNER_AWS_DEFAULT_REGION }} | |
- name: Upload package to S3 | |
run: aws s3 cp ./nodejs/packages/layer/build/layer.zip s3://${{ vars.SIGNER_BUCKET }}/to-be-signed/nodejs-layer.zip | |
- name: Get S3 version of the uploaded file | |
run: | | |
LATEST_VERSION=$(aws s3api list-object-versions --bucket ${{ vars.SIGNER_BUCKET }} --prefix to-be-signed/nodejs-layer.zip --query 'Versions[?IsLatest].[VersionId]' --output text) | |
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV | |
- name: Sign the package | |
uses: clowdhaus/[email protected] | |
with: | |
aws-region: ${{ vars.SIGNER_AWS_DEFAULT_REGION }} | |
source-s3-bucket: ${{ vars.SIGNER_BUCKET }} | |
source-s3-key: to-be-signed/nodejs-layer.zip | |
source-s3-version: ${{ env.LATEST_VERSION }} | |
destination-s3-bucket: ${{ vars.SIGNER_BUCKET }} | |
destination-s3-prefix: signed/ | |
profile-name: ${{ vars.SIGNER_PROFILE_NAME }} | |
max-wait-time: 60 | |
rename-signed-object: true | |
- name: Download the signed package from S3 | |
run: aws s3 cp s3://${{ vars.SIGNER_BUCKET }}/signed/nodejs-layer.zip ./layer.zip | |
- name: Upload package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: layer.zip | |
path: ./layer.zip | |
if-no-files-found: error | |
retention-days: 1 | |
publish-layer: | |
runs-on: ubuntu-22.04 | |
if: ${{ github.ref == 'refs/heads/coralogix-nodejs-autoinstrumentation' || inputs.environment == 'test' }} | |
needs: [package] | |
environment: ${{ inputs.environment }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ vars.LAYER_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.LAYER_AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ vars.LAYER_AWS_DEFAULT_REGION }} | |
- name: create target dir | |
run: mkdir -p target | |
- name: Download layer.zip | |
uses: actions/download-artifact@v3 | |
with: | |
name: layer.zip | |
path: target | |
- name: Publish layer | |
env: | |
LAYER_NAME: "coralogix-opentelemetry-nodejs-wrapper" | |
COMPATIBLE_RUNTIMES: "nodejs16.x nodejs18.x nodejs20.x" | |
run: ./ci-scripts/publish_${{ inputs.environment }}.sh |