-
Notifications
You must be signed in to change notification settings - Fork 455
335 lines (320 loc) · 11.4 KB
/
release_next.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
name: Release @next
on:
push:
branches:
- main
workflow_dispatch: {}
env:
SENTRY_ORG: hashicorp
SENTRY_PROJECT: cdktf-cli
concurrency:
group: release-next
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 }}
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
env:
CHECKPOINT_DISABLE: "1"
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0 # gives standard-version 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: installing dependencies
run: yarn install --frozen-lockfile
- name: Configure git user
run: |
git config user.name github-team-tf-cdk
git config user.email github-team-tf-cdk@hashicorp.com
- run: |
yarn prepare-next-release
tools/align-version.sh
- 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
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: dist
path: dist
- name: Upload edge-provider bindings
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: ${{ !inputs.skip_setup }}
with:
name: edge-provider-bindings
path: packages/@cdktf/provider-generator/edge-provider-bindings
- name: publish tag
run: git push --follow-tags
unit_test:
uses: ./.github/workflows/unit.yml
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-next
package: ${{ matrix.package }}
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit
linting:
uses: ./.github/workflows/linting.yml
with:
concurrency_group_prefix: release-next
secrets: inherit
integration_test:
needs:
- prepare-release
uses: ./.github/workflows/integration.yml
with:
skip_setup: true
concurrency_group_prefix: release-next
secrets: inherit
provider_integration_test:
needs:
- prepare-release
uses: ./.github/workflows/provider-integration.yml
with:
skip_setup: true
concurrency_group_prefix: release-next
secrets: inherit
examples:
uses: ./.github/workflows/examples.yml
with:
concurrency_group_prefix: release-next
secrets: inherit
release_npm:
name: Release to NPM
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download build artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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 }}
NPM_DIST_TAG: next
release_pypi:
name: Release to PyPi
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download build artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download dist
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
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
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download dist
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: dist
path: dist
- name: Release
run: npx -p publib publib-nuget
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
release_golang:
name: Release Go to Github Repo
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Download dist
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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: "github-team-tf-cdk@hashicorp.com"
release_sentry:
name: Finalize the sentry release
needs:
- prepare-release
- integration_test
- provider_integration_test
- unit_test
- release_npm
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- 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
- linting
- prepare-release
- 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@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
payload: |
{
"name": "next",
"run_url": "https://github.com/hashicorp/terraform-cdk/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.FAILURE_SLACK_WEBHOOK_URL }}