-
Notifications
You must be signed in to change notification settings - Fork 20
166 lines (145 loc) · 6.44 KB
/
release.yaml
File metadata and controls
166 lines (145 loc) · 6.44 KB
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
name: Create release
on:
push:
tags:
- '*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # Required for creating releases
env:
COMMIT_SHA: ${{ github.sha }}
VERSION_NUM: ${{ github.event.inputs.version || github.ref_name }}
SAGEMAKER_ARTIFACT_PREFIX: "code-editor-sagemaker-server"
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate tag
run: |
if ! echo "$VERSION_NUM" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$'; then
echo "Tag $VERSION_NUM does not follow semantic version pattern (x.y.z or x.y.z-rc.N). Skipping release."
exit 78 # neutral exit code
fi
echo "Tag $VERSION_NUM follows valid semantic version pattern"
# Verify release tag is made on the correct major.minor version branch.
MAJOR_MINOR=$(echo "$VERSION_NUM" | cut -d'.' -f1,2)
BRANCH_CONTAINS_OUTPUT=$(git branch --remote --contains "$COMMIT_SHA" "origin/$MAJOR_MINOR")
if [ -z "$BRANCH_CONTAINS_OUTPUT" ]; then
echo "Tag $VERSION_NUM is not on the correct branch. Skipping release."
exit 78
fi
echo "Tag is from a valid branch."
# - name: Verify smoke tests passed
# run: |
# echo "Checking smoke test results for commit $COMMIT_SHA..."
# # Find smoke test runs for this commit
# RUN_INFO=$(gh run list --workflow=smoke-tests-sagemaker.yaml --json headSha,conclusion,status --limit 50 | \
# jq -r --arg sha "$COMMIT_SHA" '.[] | select(.headSha == $sha) | "\(.status) \(.conclusion)"' | head -1)
# if [ -z "$RUN_INFO" ]; then
# echo "Error: No smoke test run found for commit $COMMIT_SHA"
# exit 1
# fi
# STATUS=$(echo "$RUN_INFO" | cut -d' ' -f1)
# CONCLUSION=$(echo "$RUN_INFO" | cut -d' ' -f2)
# if [ "$STATUS" != "completed" ]; then
# echo "Error: Smoke tests not completed (status: $STATUS)"
# exit 1
# fi
# if [ "$CONCLUSION" != "success" ]; then
# echo "Error: Smoke tests failed (conclusion: $CONCLUSION)"
# exit 1
# fi
# echo "Smoke tests passed for commit $COMMIT_SHA"
- name: Download sagemaker artifacts by commit ID
run: |
gh run download --name "$COMMIT_SHA-code-editor-sagemaker-server-build" --name "$COMMIT_SHA-code-editor-sagemaker-server-src"
- name: Check artifacts exist
run: |
ls -la
FILES=(
"$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-build/$SAGEMAKER_ARTIFACT_PREFIX-build.tar.gz"
"$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-src/$SAGEMAKER_ARTIFACT_PREFIX-src.tar.gz"
)
# Check build artifact exists
for file in "${FILES[@]}"; do
if [ ! -f "$file" ]; then
echo "Error: $file not found for commit $COMMIT_SHA"
exit 1
fi
done
- name: Update Code Editor version
run: |
tar xzf "$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-src/$SAGEMAKER_ARTIFACT_PREFIX-src.tar.gz"
cd code-editor-src
CURRENT_VERSION=$(jq -r '.codeEditorVersion' product.json)
jq ".codeEditorVersion = \"$VERSION_NUM\"" product.json > temp.json && mv temp.json product.json
cd ..
tar -czf "code-editor-sagemaker-src-$VERSION_NUM.tar.gz" code-editor-src/
rm -rf code-editor-src
tar xzf "$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-build/$SAGEMAKER_ARTIFACT_PREFIX-build.tar.gz"
cd vscode-reh-web-linux-x64
# Update Code Editor Version in all files
jq ".codeEditorVersion = \"$VERSION_NUM\"" product.json > temp.json && mv temp.json product.json
FILES_TO_UPDATE=(
"out/server-main.js"
"out/vs/code/browser/workbench/workbench.js"
"out/vs/platform/terminal/node/ptyHostMain.js"
"out/vs/workbench/api/node/extensionHostProcess.js"
)
for file in "${FILES_TO_UPDATE[@]}"; do
sed -i "s/codeEditorVersion:\s*\"$CURRENT_VERSION\"/codeEditorVersion:\"$VERSION_NUM\"/g" "$file"
done
cd ..
tar -czf "code-editor-sagemaker-server-$VERSION_NUM.tar.gz" vscode-reh-web-linux-x64/
rm -rf vscode-reh-web-linux-x64
- name: Create GitHub release
run: |
# Check if this is a release candidate
PRERELEASE_FLAG=""
if echo "$VERSION_NUM" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$'; then
PRERELEASE_FLAG="--prerelease"
echo "Detected release candidate version, will mark as prerelease"
fi
# Check if release already exists. Needed when release created via new release in guthub ui
if gh release view "$VERSION_NUM" > /dev/null 2>&1; then
echo "Release for tag $VERSION_NUM already exists, uploading additional assets..."
gh release upload "$VERSION_NUM" ./*.tar.gz --clobber
else
echo "Creating new release for tag $VERSION_NUM..."
gh release create "$VERSION_NUM" ./*.tar.gz \
--title "Release $VERSION_NUM" \
--notes "Release $VERSION_NUM" \
$PRERELEASE_FLAG
fi
handle-failures:
name: Handle Failures
runs-on: ubuntu-latest
needs: release
environment: release-workflow-env
if: failure()
permissions:
id-token: write # Required for OIDC
env:
REPOSITORY: ${{ github.repository }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
steps:
- name: Use role credentials for metrics
id: aws-creds
continue-on-error: ${{ env.REPOSITORY != 'aws/code-editor' }}
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
aws-region: us-east-1
- name: Report failure
if: steps.aws-creds.outcome == 'success'
run: |
aws cloudwatch put-metric-data \
--namespace "GitHub/Workflows" \
--metric-name "ExecutionsFailed" \
--dimensions "Repository=$REPOSITORY,Workflow=Release" \
--value 1