-
Notifications
You must be signed in to change notification settings - Fork 135
158 lines (138 loc) · 5.67 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
# When triggered it will publish the release only if the changes are related to the
# release
name: release
on:
workflow_dispatch:
inputs:
dry-run:
type: boolean
description: 'Run release process in dry-run mode'
default: true
permissions:
contents: read
env:
ELASTIC_CDN_BUCKET_NAME: ${{ inputs.dry-run == false && 'apm-rum-357700bc' || 'oblt-apm-rum-test' }}
ELASTIC_CDN_PROJECT_NUMBER: ${{ inputs.dry-run == false && '382950469386' || '911195782929' }}
SLACK_BUILD_MESSAGE: "Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>)"
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
services:
verdaccio:
image: verdaccio/verdaccio:5
ports:
- 4873:4873
steps:
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
repositories: >-
["apm-agent-rum-js"]
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.get_token.outputs.token }}
- uses: elastic/oblt-actions/git/setup@v1
with:
github-token: ${{ steps.get_token.outputs.token }}
# Temporary fix for "ValueError: invalid mode: 'rU' while trying to load binding.gyp"
# See https://github.com/nodejs/node-gyp/issues/2219
# This can be removed when "node-gyp" is updated
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
# This prevent lerna command from throwing this error:
# "Working tree has uncommitted changes, please commit or remove the following changes before continuing"
- name: Ignore git uncommitted changes
run: |
git update-index --skip-worktree .npmrc
- name: Publish the release
env:
DRY_RUN: "${{ inputs.dry-run }}"
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm run ci:release
# The permissions configuration for this can be found at
# https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/apm-agent-rum-js/02-gcp-oidc-elastic-cdn.tf
# and
# https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/apm-agent-rum-js/02-gcp-oidc-elastic-observability.tf
- uses: elastic/oblt-actions/google/auth@v1
with:
project-number: ${{ env.ELASTIC_CDN_PROJECT_NUMBER }}
- id: prepare-release
name: 'Prepare CDN release'
run: echo "versions=$(npm run --silent ci:prepare-release)" >> ${GITHUB_OUTPUT}
env:
# as long as we use the GitHub app for generating the token, we need to pass the token to the action
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
- id: 'upload-files-version'
if: ${{ always() && hashFiles('packages/rum/dist/bundles/*.js') }}
uses: 'google-github-actions/upload-cloud-storage@v2'
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
headers: |-
cache-control: public,max-age=31536000,immutable
- id: 'upload-files-major-version'
if: ${{ always() && hashFiles('packages/rum/dist/bundles/*.js') }}
uses: 'google-github-actions/upload-cloud-storage@v2'
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
headers: |-
cache-control: public,max-age=604800,immutable
- id: 'upload-file-index'
if: ${{ always() && hashFiles('index.html') }}
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
parent: false
path: 'index.html'
destination: '${{ env.ELASTIC_CDN_BUCKET_NAME }}'
process_gcloudignore: false
headers: |-
cache-control: public,max-age=604800,immutable
- name: Post-release
env:
DRY_RUN: "${{ inputs.dry-run }}"
# as long as we use the GitHub app for generating the token, we need to pass the token to the action
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
run: npm run ci:post-release
- if: ${{ success() && inputs.dry-run == false }}
uses: elastic/oblt-actions/slack/send@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-js"
message: |
:runner: [${{ github.repository }}] Release has been published. ${{ env.SLACK_BUILD_MESSAGE }}
- if: ${{ failure() && inputs.dry-run == false }}
uses: elastic/oblt-actions/slack/send@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-js"
message: |
:ghost: [${{ github.repository }}] Release failed. ${{ env.SLACK_BUILD_MESSAGE }}