11name : Create release
22on :
3- push :
4- tags :
5- - ' *'
3+ workflow_dispatch :
4+ inputs :
5+ code_editor_version :
6+ description : ' Code Editor version'
7+ required : true
8+ type : string
9+ sagemaker_version :
10+ description : ' SageMaker Code Editor version'
11+ required : true
12+ type : string
613
714jobs :
815 release :
916 runs-on : ubuntu-latest
1017 permissions :
1118 contents : write # Required for creating releases
1219 env :
13- COMMIT_SHA : ${{ github.sha }}
14- VERSION_NUM : ${{ github.event.inputs.version || github.ref_name }}
20+ CODE_EDITOR_VERSION : ${{ github.event.inputs.code_editor_version }}
21+ SAGEMAKER_VERSION : ${{ github.event.inputs.sagemaker_version }}
1522 SAGEMAKER_ARTIFACT_PREFIX : " code-editor-sagemaker-server"
1623 GH_TOKEN : ${{ github.token }}
1724 steps :
@@ -20,22 +27,36 @@ jobs:
2027 with :
2128 fetch-depth : 0
2229
23- - name : Validate tag
30+ - name : Validate versions and create tag
2431 run : |
25- if ! echo "$VERSION_NUM " | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$'; then
26- echo "Tag $VERSION_NUM does not follow semantic version pattern (x.y.z or x.y.z-rc.N) . Skipping release."
27- exit 78 # neutral exit code
32+ if ! echo "$CODE_EDITOR_VERSION " | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$'; then
33+ echo "Code Editor version $CODE_EDITOR_VERSION does not follow semantic version pattern (x.y.z) or x.y.z-rc.N. Skipping release."
34+ exit 1
2835 fi
29- echo "Tag $VERSION_NUM follows valid semantic version pattern"
30-
31- # Verify release tag is made on the correct major.minor version branch.
32- MAJOR_MINOR=$(echo "$VERSION_NUM" | cut -d'.' -f1,2)
33- BRANCH_CONTAINS_OUTPUT=$(git branch --remote --contains "$COMMIT_SHA" "origin/$MAJOR_MINOR")
34- if [ -z "$BRANCH_CONTAINS_OUTPUT" ]; then
35- echo "Tag $VERSION_NUM is not on the correct branch. Skipping release."
36- exit 78
36+ echo "Code Editor version $CODE_EDITOR_VERSION is valid"
37+ echo "SageMaker Code Editor version $SAGEMAKER_VERSION will be mapped"
38+
39+ # Check if tag already exists
40+ if git rev-parse "$CODE_EDITOR_VERSION" >/dev/null 2>&1; then
41+ echo "Tag $CODE_EDITOR_VERSION already exists"
42+ else
43+ echo "Creating tag $CODE_EDITOR_VERSION on current commit"
44+ git tag "$CODE_EDITOR_VERSION"
45+ git push origin "$CODE_EDITOR_VERSION"
3746 fi
38- echo "Tag is from a valid branch."
47+
48+ # Get commit SHA from tag and export it
49+ TAG_COMMIT_SHA=$(git rev-parse "$CODE_EDITOR_VERSION")
50+ echo "COMMIT_SHA=$TAG_COMMIT_SHA" >> $GITHUB_ENV
51+ echo "Tag $CODE_EDITOR_VERSION points to commit $TAG_COMMIT_SHA"
52+
53+ # Verify tag is on correct branch
54+ MAJOR_MINOR=$(echo "$CODE_EDITOR_VERSION" | cut -d'.' -f1,2)
55+ if ! git branch --remote --contains "$CODE_EDITOR_VERSION" | grep -q "origin/$MAJOR_MINOR"; then
56+ echo "Error: Tag $CODE_EDITOR_VERSION is not on branch $MAJOR_MINOR. Skipping release."
57+ exit 1
58+ fi
59+ echo "Tag validation passed"
3960
4061 - name : Download sagemaker artifacts by commit ID
4162 run : |
@@ -58,21 +79,21 @@ jobs:
5879 fi
5980 done
6081
61- - name : Update Code Editor version
82+ - name : Update versions in artifacts
6283 run : |
6384 tar xzf "$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-src/$SAGEMAKER_ARTIFACT_PREFIX-src.tar.gz"
6485 cd code-editor-src
65- CURRENT_VERSION =$(jq -r '.codeEditorVersion' product.json)
66- jq ".codeEditorVersion = \"$VERSION_NUM \"" product.json > temp.json && mv temp.json product.json
86+ CURRENT_CE_VERSION =$(jq -r '.codeEditorVersion' product.json)
87+ jq ".codeEditorVersion = \"$CODE_EDITOR_VERSION\" | .sagemakerCodeEditorVersion = \"$SAGEMAKER_VERSION \"" product.json > temp.json && mv temp.json product.json
6788 cd ..
68- tar -czf "code-editor-sagemaker-src-$VERSION_NUM .tar.gz" code-editor-src/
89+ tar -czf "code-editor-sagemaker-src-$CODE_EDITOR_VERSION .tar.gz" code-editor-src/
6990 rm -rf code-editor-src
7091
7192 tar xzf "$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-build/$SAGEMAKER_ARTIFACT_PREFIX-build.tar.gz"
7293 cd vscode-reh-web-linux-x64
7394
74- # Update Code Editor Version in all files
75- jq ".codeEditorVersion = \"$VERSION_NUM \"" product.json > temp.json && mv temp.json product.json
95+ CURRENT_SM_VERSION=$(jq -r '.sagemakerCodeEditorVersion' product.json)
96+ jq ".codeEditorVersion = \"$CODE_EDITOR_VERSION\" | .sagemakerCodeEditorVersion = \"$SAGEMAKER_VERSION \"" product.json > temp.json && mv temp.json product.json
7697
7798 FILES_TO_UPDATE=(
7899 "out/server-main.js"
@@ -81,31 +102,34 @@ jobs:
81102 "out/vs/workbench/api/node/extensionHostProcess.js"
82103 )
83104 for file in "${FILES_TO_UPDATE[@]}"; do
84- sed -i "s/codeEditorVersion:\s*\"$CURRENT_VERSION\"/codeEditorVersion:\"$VERSION_NUM\"/g" "$file"
105+ sed -i "s/codeEditorVersion:\s*\"$CURRENT_CE_VERSION\"/codeEditorVersion:\"$CODE_EDITOR_VERSION\"/g" "$file"
106+ sed -i "s/sagemakerCodeEditorVersion:\s*\"$CURRENT_SM_VERSION\"/sagemakerCodeEditorVersion:\"$SAGEMAKER_VERSION\"/g" "$file"
85107 done
86108
87109 cd ..
88- tar -czf "code-editor-sagemaker-server-$VERSION_NUM .tar.gz" vscode-reh-web-linux-x64/
110+ tar -czf "code-editor-sagemaker-server-$CODE_EDITOR_VERSION .tar.gz" vscode-reh-web-linux-x64/
89111 rm -rf vscode-reh-web-linux-x64
90112
91113 - name : Create GitHub release
92114 run : |
93115 # Check if this is a release candidate
94116 PRERELEASE_FLAG=""
95- if echo "$VERSION_NUM " | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$'; then
117+ if echo "$CODE_EDITOR_VERSION " | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$'; then
96118 PRERELEASE_FLAG="--prerelease"
97119 echo "Detected release candidate version, will mark as prerelease"
98120 fi
99121
100122 # Check if release already exists. Needed when release created via new release in guthub ui
101- if gh release view "$VERSION_NUM " > /dev/null 2>&1; then
102- echo "Release for tag $VERSION_NUM already exists, uploading additional assets..."
103- gh release upload "$VERSION_NUM " ./*.tar.gz --clobber
123+ if gh release view "$CODE_EDITOR_VERSION " > /dev/null 2>&1; then
124+ echo "Release for tag $CODE_EDITOR_VERSION already exists, uploading additional assets..."
125+ gh release upload "$CODE_EDITOR_VERSION " ./*.tar.gz --clobber
104126 else
105- echo "Creating new release for tag $VERSION_NUM..."
106- gh release create "$VERSION_NUM" ./*.tar.gz \
107- --title "Release $VERSION_NUM" \
108- --notes "Release $VERSION_NUM" \
127+ echo "Creating new release for tag $CODE_EDITOR_VERSION..."
128+ gh release create "$CODE_EDITOR_VERSION" ./*.tar.gz \
129+ --title "Release $CODE_EDITOR_VERSION" \
130+ --notes "Release $CODE_EDITOR_VERSION
131+
132+ SageMaker Code Editor Version: $SAGEMAKER_VERSION" \
109133 $PRERELEASE_FLAG
110134 fi
111135 handle-failures :
0 commit comments