-
Notifications
You must be signed in to change notification settings - Fork 201
258 lines (231 loc) · 10.5 KB
/
post-release-nri-bundle.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: Post-Release Tasks (nri-bundle)
on:
release:
types: [released]
env:
ORIGINAL_REPO_NAME: ${{ github.event.repository.full_name }}
RELEASE_PATH: charts/nri-bundle
RELEASE_FILE: RELEASE.md
SLACK_FILE: RELEASE.slack
jobs:
release-notes:
if: startsWith(github.event.release.tag_name, 'nri-bundle-')
name: Publish release notes
runs-on: ubuntu-latest
outputs:
announcement: ${{ steps.slack-announcement.outputs.announcement }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: 'latest' # default is latest (stable)
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
- name: Add Helm repositories
run: |
helm repo add newrelic-infrastructure https://newrelic.github.io/nri-kubernetes
helm repo add nri-prometheus https://newrelic.github.io/nri-prometheus
helm repo add newrelic-prometheus-configurator https://newrelic.github.io/newrelic-prometheus-configurator
helm repo add nri-metadata-injection https://newrelic.github.io/k8s-metadata-injection
helm repo add newrelic-k8s-metrics-adapter https://newrelic.github.io/newrelic-k8s-metrics-adapter
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add nri-kube-events https://newrelic.github.io/nri-kube-events
helm repo add newrelic-helm-charts https://newrelic.github.io/helm-charts
helm repo add pixie-operator-chart https://pixie-operator-charts.storage.googleapis.com
helm repo add newrelic-infra-operator https://newrelic.github.io/newrelic-infra-operator
helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics
helm repo add newrelic-cdn-helm-charts https://helm-charts.newrelic.com
- name: Create release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
scripts/write-release-notes.sh ${{ env.RELEASE_FILE }} ${{ env.SLACK_FILE }}
gh release edit ${{ github.event.release.tag_name }} \
--notes-file ${{ env.RELEASE_PATH }}/${{ env.RELEASE_FILE }}
- name: Write Slack announcement
id: slack-announcement
run: |
{
echo 'announcement<<EOF'
cat ${{ env.RELEASE_PATH }}/${{ env.SLACK_FILE }}
echo EOF
} >> "$GITHUB_OUTPUT"
announce-release:
if: startsWith(github.event.release.tag_name, 'nri-bundle-')
name: Announce bundle release
runs-on: ubuntu-latest
needs: release-notes
steps:
- name: Notify release via Slack
uses: archive/github-actions-slack@v2.9.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.K8S_AGENTS_SLACK_TOKEN }}
slack-channel: ${{ secrets.HELP_K8S_AGENTS_SLACK_CHANNEL }}
slack-text: "${{ needs.release-notes.outputs.announcement }}"
update-public-docs:
if: startsWith(github.event.release.tag_name, 'nri-bundle-')
name: Update public docs
runs-on: ubuntu-latest
env:
K8S_FOLDER: src/content/docs/release-notes/infrastructure-release-notes/kubernetes-integration-release-notes
steps:
- name: Checkout `nri-kubernetes` chart
uses: actions/checkout@v4
with:
repository: 'newrelic/nri-kubernetes'
sparse-checkout: |
charts/newrelic-infrastructure/Chart.yaml
sparse-checkout-cone-mode: false
- name: Resolve versions
run: |
cd charts/newrelic-infrastructure
appVersion=$(cat ./Chart.yaml | yq '.appVersion')
version=$(cat ./Chart.yaml | yq '.version')
echo "appVersion=${appVersion}" >> "$GITHUB_ENV"
echo "version=${version}" >> "$GITHUB_ENV"
- name: Write release notes
run: |
today=$(date "+%Y-%m-%d")
{
echo "release_notes<<EOF"
echo "---"
echo "subject: Kubernetes integration"
echo "releaseDate: '${today}'"
echo "version: ${appVersion}"
echo "---"
echo ""
echo "For a detailed description of changes, see the [release notes](https://github.com/newrelic/nri-kubernetes/releases/tag/v${appVersion})."
echo ""
echo "This integration is included in the following chart versions:"
echo "* [newrelic-infrastructure-${version}](https://github.com/newrelic/nri-kubernetes/releases/tag/newrelic-infrastructure-${version})"
echo "* [${{ github.event.release.tag_name }}](https://github.com/newrelic/helm-charts/releases/tag/${{ github.event.release.tag_name }})"
echo EOF
} >> "$GITHUB_ENV"
- name: Checkout docs-website
uses: actions/checkout@v4
with:
repository: 'newrelic/docs-website'
# Token used to run authenticated git commands
token: ${{ secrets.K8S_AGENTS_BOT_TOKEN }}
sparse-checkout: |
${{ env.K8S_FOLDER }}
sparse-checkout-cone-mode: false
- name: Configure Git
run: |
git config user.name "NewRelic-K8s-Agents-Bot"
git config user.email "NewRelic-K8s-Agents-Bot@users.noreply.github.com"
- name: Create branch in forked repo
env:
GITHUB_TOKEN: ${{ secrets.K8S_AGENTS_BOT_TOKEN_FORKS }}
run: |
cd ${{ env.K8S_FOLDER }}
appVersionModified=$(echo ${appVersion} | sed 's/\./-/g' )
branchName=add_kubernetes_release_notes-$( date "+%Y-%m-%d_%H_%M" )
releaseFile=kubernetes-integration-${appVersionModified}.mdx
summary="Add release notes for Kubernetes integration v${appVersion}"
echo "releaseFile=${releaseFile}" >> "$GITHUB_ENV"
echo "summary=${summary}" >> "$GITHUB_ENV"
if [[ -e "${releaseFile}" ]]; then
echo "File '${releaseFile}' already exists. Nothing to do"
else
echo "Creating '${releaseFile}'"
echo "${release_notes}" >> ${releaseFile}
git checkout -b ${branchName}
git add ${releaseFile}
git commit --message="feat: ${summary}"
git remote add upstream https://github.com/NewRelic-K8s-Agents-Bot/docs-website.git
git push --set-upstream upstream ${branchName}
fi
- name: Create PR in original repo
env:
GITHUB_TOKEN: ${{ secrets.K8S_AGENTS_BOT_TOKEN }}
run: |
if [[ -e "${releaseFile}" ]]; then
echo "File '${releaseFile}' already exists. Nothing to do"
else
gh pr create \
--repo newrelic/docs-website \
--title "feat: ${summary}" \
--body "${summary}"
fi
update-eks-sleek:
if: startsWith(github.event.release.tag_name, 'nri-bundle-')
name: Update EKS Sleek repo
runs-on: ubuntu-latest
steps:
- name: Checkout `nri-bundle` chart
uses: actions/checkout@v4
with:
repository: 'newrelic/helm-charts'
sparse-checkout: |
charts/nri-bundle/Chart.yaml
sparse-checkout-cone-mode: false
- name: Resolve bundle version
run: |
version=$(cat charts/nri-bundle/Chart.yaml | yq '.version')
echo "version=${version}" >> "$GITHUB_ENV"
- name: Checkout eks-anywhere-addons
uses: actions/checkout@v4
with:
repository: 'aws-samples/eks-anywhere-addons'
# Token used to run authenticated git commands
token: ${{ secrets.K8S_AGENTS_BOT_TOKEN_AWS_EKS }}
sparse-checkout: |
eks-anywhere-baremetal/Addons/Partner/newrelic/newrelic.yaml
eks-anywhere-baremetal/Addons/Partner/newrelic/namespace.yaml
eks-anywhere-snow/Addons/Partner/newrelic/newrelic.yaml
eks-anywhere-snow/Addons/Partner/newrelic/namespace.yaml
eks-anywhere-vsphere/Addons/Partner/newrelic/newrelic.yaml
eks-anywhere-vsphere/Addons/Partner/newrelic/namespace.yaml
eks-cloud/Partner/newrelic/newrelic.yaml
eks-cloud/Partner/newrelic/namespace.yaml
sparse-checkout-cone-mode: false
- name: Configure Git
run: |
git config user.name "NewRelic-K8s-Agents-Bot"
git config user.email "NewRelic-K8s-Agents-Bot@users.noreply.github.com"
- name: Create branch in forked repo
env:
GITHUB_TOKEN: ${{ secrets.K8S_AGENTS_BOT_TOKEN_AWS_EKS }}
run: |
branchName=update-nri-bundle-$( date "+%Y-%m-%d_%H_%M" )
summary="Update nri-bundle to version ${version}"
echo "summary=${summary}" >> "$GITHUB_ENV"
git checkout -b ${branchName}
folders=(
'eks-anywhere-baremetal/Addons/Partner/newrelic'
'eks-anywhere-snow/Addons/Partner/newrelic'
'eks-anywhere-vsphere/Addons/Partner/newrelic'
'eks-cloud/Partner/newrelic'
)
for directory in "${folders[@]}"; do
file_name="${directory}/newrelic.yaml"
yq eval --inplace ".spec.chart.spec.version=\"${version}\"" "${file_name}"
git add ${file_name}
file_name="${directory}/namespace.yaml"
yq eval --inplace '.metadata.labels."aws.conformance.vendor-solution-version"=env(version)' "${file_name}"
git add ${file_name}
done
git commit --message="feat: ${summary}"
git remote add upstream https://github.com/NewRelic-K8s-Agents-Bot/eks-anywhere-addons.git
git push --set-upstream upstream ${branchName}
- name: Create PR in original repo
env:
GITHUB_TOKEN: ${{ secrets.K8S_AGENTS_BOT_TOKEN_AWS_EKS }}
run: |
gh pr create \
--repo aws-samples/eks-anywhere-addons \
--title "feat: ${summary}" \
--body "${summary}"
notify-failure:
if: ${{ always() && failure() }}
needs: [release-notes,announce-release,update-public-docs,update-eks-sleek]
runs-on: ubuntu-latest
steps:
- name: Notify failure via Slack
uses: archive/github-actions-slack@v2.9.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.K8S_AGENTS_SLACK_TOKEN }}
slack-channel: ${{ secrets.K8S_AGENTS_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.ORIGINAL_REPO_NAME }}`: <${{ github.server_url }}/${{ env.ORIGINAL_REPO_NAME }}/actions/runs/${{ github.run_id }}|'Post Release Tasks (nri-bundle)' failed>."