1111 type : string
1212 # This input allows you to specify which branch to create the release from.
1313 source_branch :
14- description : ' The branch to find the latest successful build artifact on .'
14+ description : ' The branch to find the artifact on and to tag for the release .'
1515 required : true
1616 type : string
1717 # We default to 'main' to make the most common case easy.
@@ -28,33 +28,55 @@ jobs:
2828 contents : write
2929
3030 steps :
31- # Step 1: Check out the repository code.
32- # This is necessary for the release action to create a Git tag in your repository.
31+ # Step 1: Check out the repository code FROM THE SPECIFIED SOURCE BRANCH.
3332 - name : Checkout code
3433 uses : actions/checkout@v4
3534 with :
3635 ref : ${{ github.event.inputs.source_branch }}
3736
37+ # Step 2: Explicitly get the commit SHA of the checked-out branch HEAD.
38+ # This ensures we are using the correct commit for tagging.
39+ - name : Get commit SHA
40+ id : get_sha
41+ run : echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
3842
39- # Step 2: Download the build artifact from your 'Build' workflow.
40- # This finds the latest successful run on the specified branch and downloads the artifact.
43+ # Step 3: Delete existing tag if you want to re-run the release.
44+ - name : Delete existing tag (if any)
45+ uses : actions/github-script@v7
46+ with :
47+ script : |
48+ const tag = '${{ github.event.inputs.version }}';
49+ try {
50+ await github.git.deleteRef({
51+ owner: context.repo.owner,
52+ repo: context.repo.repo,
53+ ref: `tags/${tag}`
54+ });
55+ console.log(`Deleted existing tag: ${tag}`);
56+ } catch (e) {
57+ console.log(`Tag ${tag} does not exist or already deleted.`);
58+ }
59+
60+ # Step 4: Download the build artifact from your 'Build' workflow.
4161 - name : Download artifact from build workflow
4262 uses : dawidd6/action-download-artifact@v6
4363 with :
4464 # IMPORTANT: This must match the 'name:' field in your build.yaml file.
4565 workflow : build.yml
46- # Use the branch from the manual input instead of hardcoding 'main' .
66+ # Use the branch from the manual input.
4767 branch : ${{ github.event.inputs.source_branch }}
68+ # Tell the action to look for artifacts created by a 'pull_request' event.
69+ event : pull_request
70+ allow_forks : true
4871 # We use a wildcard (*) because the artifact name from the build workflow
49- # contains a dynamic commit SHA (e.g., vscode-reh-web-linux-x64-0.0.0-dev-...) .
72+ # contains a dynamic commit SHA.
5073 name : npm-package
5174 # The path where the downloaded artifact will be saved.
5275 path : ./release-assets
5376 # Ensure we only get the artifact from a successful run.
5477 workflow_conclusion : success
5578
56- # Step 3: Prepare the release assets by renaming the artifact.
57- # This takes the downloaded file and gives it a clean, versioned name.
79+ # Step 5: Prepare the release assets by renaming the artifact.
5880 - name : Prepare release assets
5981 id : prepare_assets
6082 run : |
7193 VERSION_NUM="${VERSION_TAG#v}"
7294
7395 # Create the new, clean filename for the release.
74- # This is the standardized name that your conda-forge recipe will expect.
75- NEW_FILENAME="sagemaker-code-editor-linux-x64-${VERSION_NUM}.tar.gz"
96+ NEW_FILENAME="code-editor${VERSION_NUM}.tar.gz"
7697
7798 # Rename the file.
7899 mv "$ARTIFACT_FILE" "./release-assets/$NEW_FILENAME"
81102 # Set the new filename as an output for the next step.
82103 echo "filename=./release-assets/$NEW_FILENAME" >> $GITHUB_OUTPUT
83104
84- # Step 4: Create the GitHub Release and upload the prepared asset.
85- # This action creates the tag, the release, and uploads your .tar.gz file.
105+ # Step 6: Create the GitHub Release using the CORRECT commit SHA.
86106 - name : Create GitHub Release
87107 uses : softprops/action-gh-release@v2
88108 with :
@@ -92,8 +112,10 @@ jobs:
92112 tag_name : ${{ github.event.inputs.version }}
93113 # Path to the file(s) to upload as release assets.
94114 files : ${{ steps.prepare_assets.outputs.filename }}
95- # Set to 'false' to publish immediately, or 'true' to create a draft .
115+ # Set to 'false' to publish immediately.
96116 draft : false
97- # Automatically generate release notes from commits since the last release.
98- generate_release_notes : true
99-
117+ # Set to false as we are not using auto-generated notes.
118+ generate_release_notes : false
119+ # CRITICAL: Force the tag to be created on the commit we explicitly got in Step 2.
120+ # This overrides any incorrect metadata from the downloaded artifact.
121+ target_commitish : ${{ steps.get_sha.outputs.sha }}
0 commit comments