Skip to content

Commit 7924f60

Browse files
authored
Merge pull request #165 from harvenstar/1.8
Add unit test and e2e test placeholders to build workflow
2 parents 5a44e1c + bc6802e commit 7924f60

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ on:
99
description: 'The release version (e.g., v1.8.0). This will be used to create the Git tag.'
1010
required: true
1111
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.
1313
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.'
1515
required: true
1616
type: string
17-
# We default to 'main' to make the most common case easy.
1817
default: 'main'
1918

2019
jobs:
@@ -28,54 +27,54 @@ jobs:
2827
contents: write
2928

3029
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.
3231
- name: Checkout code
3332
uses: actions/checkout@v4
3433
with:
34+
# This ensures we are on the correct branch to get the latest code.
3535
ref: ${{ github.event.inputs.source_branch }}
36+
# CRITICAL: We check out the code from the AWS repository directly.
37+
repository: aws/sagemaker-code-editor
3638

3739
# Step 2: Explicitly get the commit SHA of the checked-out branch HEAD.
38-
# This ensures we are using the correct commit for tagging.
3940
- name: Get commit SHA
4041
id: get_sha
4142
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
4243

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.
4445
- name: Delete existing tag (if any)
4546
uses: actions/github-script@v7
4647
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
4749
script: |
4850
const tag = '${{ github.event.inputs.version }}';
4951
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',
5355
ref: `tags/${tag}`
5456
});
5557
console.log(`Deleted existing tag: ${tag}`);
5658
} catch (e) {
59+
if (e.status !== 404) {
60+
// Re-throw the error if it's not a "Not Found" error
61+
throw e;
62+
}
5763
console.log(`Tag ${tag} does not exist or already deleted.`);
5864
}
5965
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.
6167
- name: Download artifact from build workflow
6268
uses: dawidd6/action-download-artifact@v6
6369
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
6574
workflow: build.yml
66-
# Use the branch from the manual input.
6775
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.
7576
name: npm-package
76-
# The path where the downloaded artifact will be saved.
7777
path: ./release-assets
78-
# Ensure we only get the artifact from a successful run.
7978
workflow_conclusion: success
8079

8180
# Step 5: Prepare the release assets by renaming the artifact.
@@ -86,7 +85,7 @@ jobs:
8685
ARTIFACT_FILE=$(find ./release-assets -name "*.tar.gz")
8786
8887
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."
9089
exit 1
9190
fi
9291
@@ -95,7 +94,6 @@ jobs:
9594
VERSION_NUM="${VERSION_TAG#v}"
9695
9796
# Create the new, clean filename for the release.
98-
9997
NEW_FILENAME="code-editor${VERSION_NUM}.tar.gz"
10098
10199
# Rename the file.
@@ -105,23 +103,18 @@ jobs:
105103
# Set the new filename as an output for the next step.
106104
echo "filename=./release-assets/$NEW_FILENAME" >> $GITHUB_OUTPUT
107105
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.
111107
- name: Create GitHub Release
112108
uses: softprops/action-gh-release@v2
113109
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
115114
name: CodeEditor ${{ github.event.inputs.version }}
116-
# The Git tag to create, e.g., "v1.8.0".
117115
tag_name: ${{ github.event.inputs.version }}
118-
# Path to the file(s) to upload as release assets.
119116
files: ${{ steps.prepare_assets.outputs.filename }}
120-
# Set to 'false' to publish immediately.
121117
draft: false
122-
# Set to false as we are not using auto-generated notes.
123118
generate_release_notes: false
124119
# 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

Comments
 (0)