-
Notifications
You must be signed in to change notification settings - Fork 232
286 lines (278 loc) · 11.8 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
name: Release
on:
workflow_dispatch:
inputs:
generateDocOnly:
description: "Generate documentation only. Unchecking this checkbox will have no impact, the documentation will still be only generated when the workflow is triggered manually."
type: boolean
required: false
default: true
push:
branches:
- "release/v*"
jobs:
release:
name: Create Release
# We don't want to do a release if the workflow was dispatched manually
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
release-asset-url: ${{ steps.create_release.outputs.upload_url }}
numeric-release-short: ${{ steps.format.outputs.numeric_release_short }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: true
- name: Format Branch Name
id: format
env:
GITHUB_REF: ${{ github.ref }}
run: |
git fetch --tags
echo ::set-output name=branch_name::$(echo "${GITHUB_REF}" | cut -d/ -f3-)
echo ::set-output name=tag_name::$(echo "${GITHUB_REF}" | cut -d/ -f4-)
echo ::set-output name=numeric_release::$(echo "${GITHUB_REF}" | cut -d/ -f4- | tr -d v)
echo ::set-output name=numeric_release_short::$(echo "${GITHUB_REF}" | cut -d/ -f4- | tr -d v.-)
echo ::set-output name=release_name::"Release $(echo "${GITHUB_REF}" | cut -d/ -f4-)"
- name: Use Node.js
uses: actions/setup-node@v1
env:
RUNNER_TEMP: /tmp/runner
with:
node-version: 18
- name: Install pnpm
run: |
npm install -g [email protected]
- name: Generate Changelog
id: changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_DEFAULT_BRANCH: ${{ steps.format.outputs.branch_name }}
run: |
previous_tag=$(git describe --tags --abbrev=0)
echo "Previous release was: ${previous_tag}"
changes=$(git log ${previous_tag}..HEAD --pretty="tformat:* %s (%h)" --first-parent)
echo ${changes}
changes="${changes//'%'/'%25'}" # Avoids whitespace removal.
changes="${changes//$'\n'/'%0A'}"
changes="${changes//$'\r'/'%0D'}"
echo ::set-output name=changelog::${changes}
- name: Bump package.json
run: |
npm install -g json
git config user.name github-actions
git config user.email [email protected]
json -I -f src/core/cdk/package.json -e 'this.version="${{ steps.format.outputs.numeric_release }}"'
git add src/core/cdk/package.json
json -I -f src/installer/cdk/package.json -e 'this.version="${{ steps.format.outputs.numeric_release }}"'
git add src/installer/cdk/package.json
git commit -am 'Updating package to ${{ steps.format.outputs.numeric_release }}'
- name: Push Bumped Package Files
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.format.outputs.branch_name }}
- name: Build Accelerator Installer
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_DEFAULT_BRANCH: ${{ steps.format.outputs.branch_name }}
INSTALLER_STACK_DIR: ./src/installer/cdk
INSTALLER_STACK_NAME: AcceleratorInstaller
NUMERIC_RELEASE_SHORT: ${{ steps.format.outputs.numeric_release_short }}
OUTPUT_DIR: templates
run: |
cd "${INSTALLER_STACK_DIR}"
pnpm install --frozen-lockfile
pnpx cdk synth --output "${OUTPUT_DIR}" "${INSTALLER_STACK_NAME}"
echo ::set-output name=template_name::${INSTALLER_STACK_NAME}-GitHub.template.json
echo ::set-output name=template_name_code_commit::${INSTALLER_STACK_NAME}-CodeCommit.template.json
echo ::set-output name=template_name_with_version::${INSTALLER_STACK_NAME}${NUMERIC_RELEASE_SHORT}-GitHub.template.json
echo ::set-output name=template_name_with_version_code_commit::${INSTALLER_STACK_NAME}${NUMERIC_RELEASE_SHORT}-CodeCommit.template.json
echo ::set-output name=template_path::$(realpath "${OUTPUT_DIR}/${INSTALLER_STACK_NAME}.template.json")
echo ::set-output name=template_path_code_commit::$(realpath "${OUTPUT_DIR}/${INSTALLER_STACK_NAME}-CodeCommit.template.json")
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.format.outputs.tag_name }}
release_name: ${{ steps.format.outputs.release_name }}
body: |
${{ steps.changelog.outputs.changelog }}
draft: true
prerelease: false
- name: Upload Artifact - AcceleratorInstaller-GitHub
uses: actions/upload-artifact@v2
with:
path: ${{ steps.build.outputs.template_path }}
name: ${{ steps.build.outputs.template_name }}
- name: Upload Artifact - AcceleratorInstaller-CodeCommit
uses: actions/upload-artifact@v2
with:
path: ${{ steps.build.outputs.template_path_code_commit }}
name: ${{ steps.build.outputs.template_name_code_commit }}
- name: Upload Release Asset - AcceleratorInstaller-GitHub
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build.outputs.template_path }}
asset_name: ${{ steps.build.outputs.template_name_with_version }}
asset_content_type: application/json
- name: Upload Release Asset - AcceleratorInstaller-CodeCommit
id: upload-release-asset-code-commmit
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build.outputs.template_path_code_commit }}
asset_name: ${{ steps.build.outputs.template_name_with_version_code_commit }}
asset_content_type: application/json
- name: Get Draft Release Url
id: release_url
run: |
echo "Draft release available at: ${{ steps.create_release.outputs.html_url}}"
build-sea-config-schema:
name: Build SEA-Config-Schema
runs-on: ubuntu-latest
outputs:
release-asset-name: ${{ steps.build.outputs.release-asset-name }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: true
- name: Use Node.js
uses: actions/setup-node@v1
env:
RUNNER_TEMP: /tmp/runner
with:
node-version: 18
- name: Install pnpm
run: |
npm install -g [email protected]
- name: Build SEA-Config-Schema project
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_DIR: ./src/lib/docs-gen
OUTPUT_DIR: output-docs
BUILD_ASSET_NAME: AWS-SEA-Config-Schema-DRAFT.zip
run: |
pnpm install --frozen-lockfile
cd "${BUILD_DIR}"
pnpm build
echo ::set-output name=release-path::$(realpath "./${OUTPUT_DIR}")
echo ::set-output name=release-asset-name::${BUILD_ASSET_NAME}
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build.outputs.release-asset-name }}
path: ${{ steps.build.outputs.release-path }}
build-sea-gui:
name: Build SEA-GUI
runs-on: ubuntu-latest
outputs:
release-asset-name: ${{ steps.build.outputs.release-asset-name }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: true
- name: Use Node.js
uses: actions/setup-node@v1
env:
RUNNER_TEMP: /tmp/runner
with:
node-version: 18
- name: Install pnpm
run: |
npm install -g [email protected]
- name: Build SEA-GUI project
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_DIR: ./src/ui
OUTPUT_DIR: build
BUILD_ASSET_NAME: AWS-SEA-GUI-mockup-DoNotUse-alpha.zip
run: |
pnpm install --frozen-lockfile
cd "${BUILD_DIR}"
pnpm build:ui
echo ::set-output name=release-path::$(realpath "./${OUTPUT_DIR}")
echo ::set-output name=release-asset-name::${BUILD_ASSET_NAME}
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build.outputs.release-asset-name }}
path: ${{ steps.build.outputs.release-path }}
upload-archive-to-release:
# We don't want to upload artifact to the release if the workflow was dispatched manually
if: github.event_name != 'workflow_dispatch'
needs: [release, build-sea-gui, build-sea-config-schema]
name: Upload Archives to Release
runs-on: ubuntu-latest
steps:
- name: SEA-GUI - Download Archive
uses: actions/download-artifact@v2
id: download-archive-sea-gui
with:
name: ${{ needs.build-sea-gui.outputs.release-asset-name }}
path: download-archive-sea-gui
- name: SEA-GUI - Create Archive
id: create-archive-sea-gui
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMERIC_RELEASE_SHORT: ${{ needs.release.outputs.numeric-release-short }}
OUTPUT_DIR: ${{ steps.download-archive-sea-gui.outputs.download-path }}
run: |
cd "${OUTPUT_DIR}"
zip -r archive.zip *
echo ::set-output name=release-path::$(realpath "./archive.zip")
echo ::set-output name=release-asset-name::AWS-SEA-GUI-mockup-DoNotUse-v${NUMERIC_RELEASE_SHORT}-alpha.zip
- name: SEA-GUI - Upload Release Asset
id: upload-release-asset-sea-gui
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release-asset-url }}
asset_path: ${{ steps.create-archive-sea-gui.outputs.release-path }}
asset_name: ${{ steps.create-archive-sea-gui.outputs.release-asset-name }}
asset_content_type: application/zip
- name: SEA-Config-Schema - Download Archive
uses: actions/download-artifact@v2
id: download-archive-sea-config-schema
with:
name: ${{ needs.build-sea-config-schema.outputs.release-asset-name }}
path: download-archive-sea-config-schema
- name: SEA-Config-Schema - Create Archive
id: create-archive-sea-config-schema
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMERIC_RELEASE_SHORT: ${{ needs.release.outputs.numeric-release-short }}
OUTPUT_DIR: ${{ steps.download-archive-sea-config-schema.outputs.download-path }}
run: |
cd "${OUTPUT_DIR}"
zip -r archive.zip *
echo ::set-output name=release-path::$(realpath "./archive.zip")
echo ::set-output name=release-asset-name::AWS-SEA-Config-Schema-v${NUMERIC_RELEASE_SHORT}-DRAFT.zip
- name: SEA-Config-Schema - Upload Release Asset
id: upload-release-asset-sea-config-schema
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release-asset-url }}
asset_path: ${{ steps.create-archive-sea-config-schema.outputs.release-path }}
asset_name: ${{ steps.create-archive-sea-config-schema.outputs.release-asset-name }}
asset_content_type: application/zip