9
9
description : ' The release version (e.g., v1.8.0). This will be used to create the Git tag.'
10
10
required : true
11
11
type : string
12
- # This input allows you to specify which branch to create the release from.
12
+ # This input specifies the branch to tag and release from.
13
13
source_branch :
14
- description : ' The branch to find the artifact on and to tag for the release .'
14
+ description : ' The branch to create the release from (e.g., main or 1.8). This branch MUST have the final code .'
15
15
required : true
16
16
type : string
17
- # We default to 'main' to make the most common case easy.
18
17
default : ' main'
19
18
20
19
jobs :
@@ -28,54 +27,54 @@ jobs:
28
27
contents : write
29
28
30
29
steps :
31
- # Step 1: Check out the repository code FROM THE SPECIFIED SOURCE BRANCH.
30
+ # Step 1: Check out the code from the SPECIFIED BRANCH in the AWS repository .
32
31
- name : Checkout code
33
32
uses : actions/checkout@v4
34
33
with :
34
+ # This ensures we are on the correct branch to get the latest code.
35
35
ref : ${{ github.event.inputs.source_branch }}
36
+ # CRITICAL: We check out the code from the AWS repository directly.
37
+ repository : aws/sagemaker-code-editor
36
38
37
39
# 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
40
- name : Get commit SHA
40
41
id : get_sha
41
42
run : echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
42
43
43
- # Step 3: Delete existing tag if you want to re-run the release.
44
+ # Step 3: Delete existing tag in the AWS repo if you want to re-run the release.
44
45
- name : Delete existing tag (if any)
45
46
uses : actions/github-script@v7
46
47
with :
48
+ github-token : ${{ secrets.GITHUB_TOKEN }}
47
49
script : |
48
50
const tag = '${{ github.event.inputs.version }}';
49
51
try {
50
- await github.git.deleteRef({
51
- owner: context.repo.owner ,
52
- repo: context.repo.repo ,
52
+ await github.rest. git.deleteRef({
53
+ owner: 'aws' ,
54
+ repo: 'sagemaker-code-editor' ,
53
55
ref: `tags/${tag}`
54
56
});
55
57
console.log(`Deleted existing tag: ${tag}`);
56
58
} catch (e) {
59
+ if (e.status !== 404) {
60
+ // Re-throw the error if it's not a "Not Found" error
61
+ throw e;
62
+ }
57
63
console.log(`Tag ${tag} does not exist or already deleted.`);
58
64
}
59
65
60
- # Step 4: Download the build artifact from your 'Build' workflow .
66
+ # Step 4: Download the build artifact from the UPSTREAM repository after a PUSH event .
61
67
- name : Download artifact from build workflow
62
68
uses : dawidd6/action-download-artifact@v6
63
69
with :
64
- # IMPORTANT: This must match the 'name:' field in your build.yaml file.
70
+ # CRITICAL: Explicitly specify the repository where the build artifact was created.
71
+ repo : aws/sagemaker-code-editor
72
+ # BEST PRACTICE: Look for artifacts created by a 'push' event (e.g., after a PR is merged).
73
+ event : push
65
74
workflow : build.yml
66
- # Use the branch from the manual input.
67
75
branch : ${{ github.event.inputs.source_branch }}
68
-
69
- # Tell the action to look for artifacts created by a 'pull_request' event.
70
- event : pull_request
71
- allow_forks : true
72
-
73
- # We use a wildcard (*) because the artifact name from the build workflow
74
- # contains a dynamic commit SHA.
75
76
name : npm-package
76
- # The path where the downloaded artifact will be saved.
77
77
path : ./release-assets
78
- # Ensure we only get the artifact from a successful run.
79
78
workflow_conclusion : success
80
79
81
80
# Step 5: Prepare the release assets by renaming the artifact.
86
85
ARTIFACT_FILE=$(find ./release-assets -name "*.tar.gz")
87
86
88
87
if [ -z "$ARTIFACT_FILE" ]; then
89
- echo "::error::Build artifact not found in ./release-assets! Make sure the 'Build ' workflow ran successfully on the '${{ github.event.inputs.source_branch }}' branch."
88
+ echo "::error::Build artifact not found! Ensure a 'build.yml ' workflow ran successfully on the '${{ github.event.inputs.source_branch }}' branch in 'aws/sagemaker-code-editor' after the code was pushed/merged ."
90
89
exit 1
91
90
fi
92
91
95
94
VERSION_NUM="${VERSION_TAG#v}"
96
95
97
96
# Create the new, clean filename for the release.
98
-
99
97
NEW_FILENAME="code-editor${VERSION_NUM}.tar.gz"
100
98
101
99
# Rename the file.
@@ -105,23 +103,18 @@ jobs:
105
103
# Set the new filename as an output for the next step.
106
104
echo "filename=./release-assets/$NEW_FILENAME" >> $GITHUB_OUTPUT
107
105
108
-
109
- # Step 6: Create the GitHub Release using the CORRECT commit SHA.
110
-
106
+ # Step 6: Create the GitHub Release in the AWS repo using the CORRECT commit SHA.
111
107
- name : Create GitHub Release
112
108
uses : softprops/action-gh-release@v2
113
109
with :
114
- # The name of the release, e.g., "Release v1.8.0".
110
+ # We need a token with permissions to create releases in the AWS repo.
111
+ token : ${{ secrets.GITHUB_TOKEN }}
112
+ # CRITICAL: Explicitly specify the repository to create the release in.
113
+ repository : aws/sagemaker-code-editor
115
114
name : CodeEditor ${{ github.event.inputs.version }}
116
- # The Git tag to create, e.g., "v1.8.0".
117
115
tag_name : ${{ github.event.inputs.version }}
118
- # Path to the file(s) to upload as release assets.
119
116
files : ${{ steps.prepare_assets.outputs.filename }}
120
- # Set to 'false' to publish immediately.
121
117
draft : false
122
- # Set to false as we are not using auto-generated notes.
123
118
generate_release_notes : false
124
119
# CRITICAL: Force the tag to be created on the commit we explicitly got in Step 2.
125
- # This overrides any incorrect metadata from the downloaded artifact.
126
- target_commitish : ${{ steps.get_sha.outputs.sha }}
127
-
120
+ target_commitish : ${{ steps.get_sha.outputs.sha }}
0 commit comments