-
Notifications
You must be signed in to change notification settings - Fork 454
371 lines (355 loc) · 12.9 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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: Release
on:
push:
branches:
- main
- backport-release-*
workflow_dispatch: {}
env:
SENTRY_ORG: hashicorp
SENTRY_PROJECT: cdktf-cli
concurrency:
group: release
jobs:
prepare-release:
if: github.repository == 'hashicorp/terraform-cdk'
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.build-test-matrix.outputs.tests }}
version: ${{ steps.get_version.outputs.version }}
release_status: ${{ steps.get_release_status.outputs.release }}
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
env:
CHECKPOINT_DISABLE: "1"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # gives sentry access to all previous commits
- name: "Add Git safe.directory" # Go 1.18+ started embedding repo info in the build and e.g. building @cdktf/hcl2json fails without this
# The Sentry CLI also requires this, https://github.com/actions/checkout/issues/760
run: git config --global --add safe.directory /__w/terraform-cdk/terraform-cdk
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: version
id: get_version
run: |
version=$(node -p "require('./package.json').version")
echo "version=${version}" >> $GITHUB_OUTPUT
- name: release status
id: get_release_status
run: |
status=$(sentry-cli releases list | grep -q 'cdktf-cli-${{ steps.get_version.outputs.version }} ' && echo 'released' || echo 'unreleased')
echo "Sentry returned: ${status}"
echo "release=${status}" >> $GITHUB_OUTPUT
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
- name: Create a release
if: steps.get_release_status.outputs.release == 'unreleased'
run: sentry-cli releases new cdktf-cli-${{ steps.get_version.outputs.version }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
- name: create bundle
run: |
yarn install --frozen-lockfile
tools/align-version.sh
yarn build
yarn package
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Add sourcemap and commit info to sentry
if: steps.get_release_status.outputs.release == 'unreleased'
run: |
sentry-cli releases files cdktf-cli-${{ steps.get_version.outputs.version }} upload-sourcemaps ./packages/cdktf-cli/bundle
sentry-cli releases set-commits --auto cdktf-cli-${{ steps.get_version.outputs.version }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: dist
path: dist
- name: Upload edge-provider bindings
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ !inputs.skip_setup }}
with:
name: edge-provider-bindings
path: packages/@cdktf/provider-generator/edge-provider-bindings
integration_test:
uses: ./.github/workflows/integration.yml
needs:
- prepare-release
if: needs.prepare-release.outputs.release_status == 'unreleased'
with:
skip_setup: true
concurrency_group_prefix: release
secrets: inherit
provider_integration_test:
needs:
- prepare-release
uses: ./.github/workflows/provider-integration.yml
if: needs.prepare-release.outputs.release_status == 'unreleased'
with:
concurrency_group_prefix: release
skip_setup: true
secrets: inherit
examples:
needs:
- prepare-release
uses: ./.github/workflows/examples.yml
if: needs.prepare-release.outputs.release_status == 'unreleased'
with:
concurrency_group_prefix: release
secrets: inherit
linting:
needs:
- prepare-release
uses: ./.github/workflows/linting.yml
if: needs.prepare-release.outputs.release_status == 'unreleased'
with:
concurrency_group_prefix: release
secrets: inherit
unit_test:
uses: ./.github/workflows/unit.yml
needs:
- prepare-release
if: needs.prepare-release.outputs.release_status == 'unreleased'
strategy:
fail-fast: false
matrix:
package:
[
cdktf,
cdktf-cli,
"@cdktf/hcl2cdk",
"@cdktf/hcl2json",
"@cdktf/provider-generator",
"@cdktf/provider-schema",
"@cdktf/commons",
"@cdktf/cli-core",
]
terraform_version: ["1.6.5", "1.5.5"]
with:
concurrency_group_prefix: release
package: ${{ matrix.package }}
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit
release_github:
name: Release to Github
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: installing dependencies
run: |
yarn install --frozen-lockfile
- name: Download build artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: dist
- name: Release to github
run: yarn release-github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_npm:
name: Release to Github Packages NPM regitry
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download build artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: dist
path: dist
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Release
run: npx -p publib publib-npm
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
release_pypi:
name: Release to PyPi
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download build artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: dist
path: dist
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
# We use twine directly for publishing instead of publib-pypi
# Publib-pypi does the same twine command (https://github.com/cdklabs/publib/blob/main/bin/publib-pypi)
# but also tries to install twine which is already globally
# available in the docker image we use. It upgrades twine,
# introducing risks of breaking changes. (Though not likely, twine is ancient)
# We can not keep the install since the update to python 3.11 in the docker image
# forbids global installs since the global pip is system managed.
# Running this install in a virtualenv would be possible but would require
# changes for the publib-pypi script. This is the easiest solution for now.
- name: Release
run: |
cd dist/python
twine upload --verbose --skip-existing *
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
release_maven:
name: Release to Maven
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download build artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: dist
path: dist
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Release
run: npx -p publib publib-maven
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_ENDPOINT: https://hashicorp.oss.sonatype.org
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
MAVEN_GPG_PRIVATE_KEY_PASSPHRASE: ${{ secrets.MAVEN_GPG_PRIVATE_KEY_PASSPHRASE }}
MAVEN_STAGING_PROFILE_ID: ${{ secrets.MAVEN_STAGING_PROFILE_ID }}
MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" # See https://stackoverflow.com/questions/70153962/nexus-staging-maven-plugin-maven-deploy-failed-an-api-incompatibility-was-enco
release_nuget:
name: Release to NuGet
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download dist
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: dist
path: dist
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Release
run: npx -p publib publib-nuget
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
release_golang:
name: Release Go to Github Repo
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download dist
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: dist
path: dist
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Release
run: npx -p publib publib-golang
env:
GITHUB_TOKEN: ${{ secrets.TERRAFORM_CDK_GO_REPO_GITHUB_TOKEN }}
GIT_USER_NAME: "CDK for Terraform Team"
GIT_USER_EMAIL: "[email protected]"
release_sentry:
name: Finalize the sentry release
runs-on: ubuntu-latest
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
if: needs.prepare-release.outputs.release_status == 'unreleased'
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: version
id: get_version
run: |
version=$(node -p "require('./package.json').version")
echo "version=${version}" >> $GITHUB_OUTPUT
- name: release status
id: get_release_status
run: |
status=$(sentry-cli releases list | grep 'cdktf-cli-${{ steps.get_version.outputs.version }} ' | grep -q 'unreleased' && echo "unreleased" || echo "released")
echo "Sentry returned: ${status}"
echo "release=${status}" >> $GITHUB_OUTPUT
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
- name: Finalize the release
if: steps.get_release_status.outputs.release == 'unreleased'
run: sentry-cli releases finalize cdktf-cli-${{ steps.get_version.outputs.version }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
report:
name: Report status
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- examples
- integration_test
- provider_integration_test
- linting
- prepare-release
- release_github
- release_golang
- release_maven
- release_npm
- release_nuget
- release_pypi
- release_sentry
- unit_test
steps:
- name: Send failures to Slack
uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e # v1.26.0
with:
payload: |
{
"name": "main",
"run_url": "https://github.com/hashicorp/terraform-cdk/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.FAILURE_SLACK_WEBHOOK_URL }}