Adjust jq strings #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version' | |
required: true | |
type: string | |
push: | |
tags: | |
- '*' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # Required for creating releases | |
environment: release-workflow-env | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMIT_SHA: ${{ github.sha }} | |
REPOSITORY: ${{ github.repository }} | |
VERSION_NUM: ${{ github.event.inputs.version || github.ref_name }} | |
SAGEMAKER_ARTIFACT_PREFIX: "code-editor-sagemaker-server" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Validate tag format | |
run: | | |
if ! echo "$VERSION_NUM" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
echo "Tag $VERSION_NUM does not follow semantic version pattern (x.y.z). Skipping release." | |
exit 78 # neutral exit code | |
fi | |
echo "Tag $VERSION_NUM follows valid semantic version pattern" | |
- name: Check if tag is from release branch | |
run: | | |
# Get the branch that contains this tag | |
BRANCHES=$(git branch -r --contains $COMMIT_SHA | grep -E 'origin/[0-9]+\.[0-9]+' || true) | |
if [ -z "$BRANCHES" ]; then | |
echo "Tag $VERSION_NUM is not from a *.* release branch. Skipping release." | |
exit 78 # neutral exit code | |
fi | |
echo "Tag is from a valid release branch: $BRANCHES" | |
- 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: Untar, Inject current Code Editor Version and Re-tar | |
run: | | |
tar xzf "$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-build/$SAGEMAKER_ARTIFACT_PREFIX-build.tar.gz" | |
cd vscode-reh-web-linux-x64 | |
jq ".codeEditorVersion = \"$VERSION_NUM\"" product.json > temp.json && mv temp.json product.json | |
cd .. | |
tar -czf "code-editor-sagemaker-server-$VERSION_NUM.tar.gz" vscode-reh-web-linux-x64/ | |
rm -rf vscode-reh-web-linux-x64 | |
tar xzf "$COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-src/$SAGEMAKER_ARTIFACT_PREFIX-src.tar.gz" | |
cd code-editor-src | |
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 | |
- name: Create GitHub release | |
run: | | |
# 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" | |
fi |