release #52
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: release | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
type: boolean | |
description: 'Run release process in dry-run mode' | |
default: true | |
permissions: | |
contents: read | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
# Needed to write the release changelog | |
contents: write | |
services: | |
verdaccio: | |
image: verdaccio/verdaccio:5 | |
ports: | |
- 4873:4873 | |
steps: | |
- name: Configure github token | |
uses: elastic/apm-pipeline-library/.github/actions/github-token@current | |
with: | |
url: ${{ secrets.VAULT_ADDR }} | |
roleId: ${{ secrets.VAULT_ROLE_ID }} | |
secretId: ${{ secrets.VAULT_SECRET_ID }} | |
- name: Configure git user | |
uses: elastic/apm-pipeline-library/.github/actions/setup-git@current | |
with: | |
username: ${{ env.GIT_USER }} | |
email: ${{ env.GIT_EMAIL }} | |
token: ${{ env.GITHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ env.GITHUB_TOKEN }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Install dependencies | |
run: npm ci | |
- name: Read NPM vault secrets | |
if: inputs.dry-run == false | |
uses: hashicorp/[email protected] | |
with: | |
method: approle | |
url: ${{ secrets.VAULT_ADDR }} | |
roleId: ${{ secrets.VAULT_ROLE_ID }} | |
secretId: ${{ secrets.VAULT_SECRET_ID }} | |
secrets: | | |
totp/code/npmjs-elasticmachine code | TOTP_CODE | |
- name: Configure npm registry | |
uses: elastic/apm-pipeline-library/.github/actions/setup-npmrc@current | |
if: inputs.dry-run == false | |
with: | |
vault-url: ${{ secrets.VAULT_ADDR }} | |
vault-role-id: ${{ secrets.VAULT_ROLE_ID }} | |
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }} | |
secret: secret/jenkins-ci/npmjs/elasticmachine | |
secret-key: token | |
- name: Publish the release | |
env: | |
DRY_RUN: ${{ inputs.dry-run }} | |
run: npm run ci:release | |
- name: Setup credentials | |
env: | |
DRY_RUN: ${{ inputs.dry-run }} | |
run: | | |
if [ "${DRY_RUN}" == "false" ]; then | |
echo 'ELASTIC_CDN_BUCKET_NAME=apm-rum-357700bc' >> ${GITHUB_ENV} | |
echo 'ELASTIC_CDN_CREDENTIALS=secret/gce/elastic-cdn/service-account/apm-rum-admin' >> ${GITHUB_ENV} | |
else | |
echo 'ELASTIC_CDN_BUCKET_NAME=oblt-apm-agent-rum-js-ci' >> ${GITHUB_ENV} | |
echo 'ELASTIC_CDN_CREDENTIALS=secret/observability-team/ci/service-account/apm-agent-rum-js' >> ${GITHUB_ENV} | |
fi | |
- name: Read GCE vault secrets | |
uses: hashicorp/[email protected] | |
with: | |
method: approle | |
url: ${{ secrets.VAULT_ADDR }} | |
roleId: ${{ secrets.VAULT_ROLE_ID }} | |
secretId: ${{ secrets.VAULT_SECRET_ID }} | |
secrets: | | |
${{ env.ELASTIC_CDN_CREDENTIALS }} value | GOOGLE_CREDENTIALS ; | |
- name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ env.GOOGLE_CREDENTIALS }}' | |
create_credentials_file: true | |
- id: prepare-release | |
name: 'Prepare CDN release' | |
run: echo "versions=$(npm run --silent ci:prepare-release)" >> ${GITHUB_OUTPUT} | |
- id: 'upload-files-version' | |
uses: 'google-github-actions/upload-cloud-storage@v1' | |
with: | |
parent: false | |
path: 'packages/rum/dist/bundles/' | |
destination: '${{ env.ELASTIC_CDN_BUCKET_NAME }}/${{ fromJSON(steps.prepare-release.outputs.versions).version }}' | |
glob: '*.js' | |
process_gcloudignore: false | |
- id: 'upload-files-major-version' | |
uses: 'google-github-actions/upload-cloud-storage@v1' | |
with: | |
parent: false | |
path: 'packages/rum/dist/bundles/' | |
destination: '${{ env.ELASTIC_CDN_BUCKET_NAME }}/${{ fromJSON(steps.prepare-release.outputs.versions).major_version }}' | |
glob: '*.js' | |
process_gcloudignore: false | |
- id: 'upload-file-index' | |
uses: 'google-github-actions/upload-cloud-storage@v1' | |
with: | |
parent: false | |
path: 'index.html' | |
destination: '${{ env.ELASTIC_CDN_BUCKET_NAME }}' | |
process_gcloudignore: false | |
status: | |
if: always() | |
needs: | |
- release | |
runs-on: ubuntu-latest | |
steps: | |
- id: check | |
uses: elastic/apm-pipeline-library/.github/actions/check-dependent-jobs@current | |
with: | |
needs: ${{ toJSON(needs) }} | |
- uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current | |
if: inputs.dry-run == false | |
with: | |
status: ${{ steps.check.outputs.status }} | |
vaultUrl: ${{ secrets.VAULT_ADDR }} | |
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} | |
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} | |
slackChannel: "#apm-agent-js" | |
message: "Build result for release publication" |