Skip to content

Merge pull request #156 from harvenstar/1.7.0 #18

Merge pull request #156 from harvenstar/1.7.0

Merge pull request #156 from harvenstar/1.7.0 #18

Workflow file for this run

name: Automated Release
# Controls when the workflow will run
on:
# Triggers the workflow on updates to the "main" branch which include a version tag
push:
tags:
- '**' # Push events to every tag including hierarchical tags like v1.0/beta
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Defines permissions granted to the GITHUB_TOKEN for this workflow run.
# 'contents: write' is needed for actions like softprops/action-gh-release to create GitHub releases
# and for peter-evans/create-pull-request if it were to commit to the same repo
permissions:
contents: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job checks if the pushed tag is a valid version tag (starts with 'v')
check-tag:
runs-on: ubuntu-latest
steps:
# This step performs the tag check
- name: Check tag is version tag
id: check # Assign an ID to this step to reference its outputs
run: |
# Check if the GitHub reference (github.ref) starts with 'refs/tags/v'
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
REF="${{ github.ref }}"
VERSION="${REF##refs/tags/v}"
echo "Tag starts with 'v'."
echo "Version: ${VERSION}"
echo "Continuing..."
# Set the version as an output variable for other jobs/steps
echo "version=${VERSION}" >> $GITHUB_OUTPUT
exit 0
else
echo "The tag doesn't start with 'v'. To release a new version, the tag must start with 'v'"
exit 1
fi
outputs:
version: ${{ steps.check.outputs.version }}
# This job builds the release tarball and publishes it to GitHub Releases
release:
# Specifies the environment for this job (if you have environments configured)
environment: release
# This job runs on the latest Ubuntu environment
runs-on: ubuntu-latest
needs: [check-tag]
container:
image: node:20
steps:
# Checks out the repository code at the specific tag that triggered the workflow
- name: Checkout the main branch
uses: actions/checkout@v4
- name: Install Dependencies
run: |
apt-get update
apt-get install -y build-essential g++ libx11-dev libxkbfile-dev libsecret-1-dev libkrb5-dev python-is-python3 quilt
# Builds the tarball
- name: Build Tarball
id: build
run: |
# Configure git safe directory for operations within the workspace
git config --global --add safe.directory /__w/sagemaker-code-editor/sagemaker-code-editor
# Run the install script to build the tarball, passing the version
sh ./scripts/install.sh -t ${{ needs.check-tag.outputs.version }}
# Define the tarball name based on the version
TARBALL_NAME="code-editor${{ needs.check-tag.outputs.version }}.tar.gz"
# Set the tarball name as an output variable
echo "tarball_name=${TARBALL_NAME}" >> $GITHUB_OUTPUT
# Calculate the SHA256 hash of the tarball
SHA256_HASH=$(sha256sum ${TARBALL_NAME} | awk '{ print $1 }')
# Set the SHA256 hash as an output variable
echo "sha256_hash=${SHA256_HASH}" >> $GITHUB_OUTPUT
# Publishes the release to GitHub Releases
- name: Publish Release
id: publish # Assign an ID to this step to reference its outputs
uses: softprops/[email protected] # Caution: Due to recent update of action-gh-release, it now requires node24. So here we still used the previous version v2.2.2
with:
# Name of the release (e.g., "Code Editor x.y.z")
name: Code Editor ${{ needs.check-tag.outputs.version }}
# Tag name for the release (e.g., "vx.y.z")
tag_name: v${{ needs.check-tag.outputs.version }}
# Files to upload as release assets
files: |
${{ steps.build.outputs.tarball_name }}
# Define outputs for this job
outputs:
sha256_hash: ${{ steps.build.outputs.sha256_hash }}
assets: ${{ steps.publish.outputs.assets }}