Skip to content

Commit 3139aa9

Browse files
authored
Update release.yml
Signed-off-by: Hudson Xing <77495133+harvenstar@users.noreply.github.com>
1 parent 7506761 commit 3139aa9

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1+
# Workflow name
12
name: Release
23

4+
# This workflow is triggered manually from the GitHub Actions tab test.
35
on:
46
workflow_dispatch:
57
inputs:
68
version:
79
description: 'The release version (e.g., v1.8.0). This will be used to create the Git tag.'
810
required: true
911
type: string
12+
# This input allows you to specify which branch to create the release from.
1013
source_branch:
1114
description: 'The branch to find the latest successful build artifact on.'
1215
required: true
1316
type: string
17+
# We default to 'main' to make the most common case easy.
1418
default: 'main'
1519

1620
jobs:
21+
# The job for creating a release
1722
create-release:
1823
name: Create Release
1924
runs-on: ubuntu-latest
2025
timeout-minutes: 30
2126
permissions:
27+
# This permission is required for creating a release and uploading assets.
2228
contents: write
2329

2430
steps:
25-
# Step 1: Checkout repository code
31+
# Step 1: Check out the repository code.
32+
# This is necessary for the release action to create a Git tag in your repository.
2633
- name: Checkout code
2734
uses: actions/checkout@v4
2835

29-
# Step 2: Delete existing tag if it exists, so the new tag is created with the release time
30-
# This ensures that the tag time and release time are always consistent
3136
- name: Delete existing tag (if any)
3237
uses: actions/github-script@v7
3338
with:
@@ -43,42 +48,69 @@ jobs:
4348
} catch (e) {
4449
console.log(`Tag ${tag} does not exist or already deleted.`);
4550
}
46-
47-
# Step 3: Download the build artifact produced by your build workflow
51+
# Step 2: Download the build artifact from your 'Build' workflow.
52+
# This finds the latest successful run on the specified branch and downloads the artifact.
4853
- name: Download artifact from build workflow
4954
uses: dawidd6/action-download-artifact@v6
5055
with:
56+
# IMPORTANT: This must match the 'name:' field in your build.yaml file.
5157
workflow: build.yml
58+
# Use the branch from the manual input instead of hardcoding 'main'.
5259
branch: ${{ github.event.inputs.source_branch }}
60+
61+
# Tell the action to look for artifacts created by a 'pull_request' event.
5362
event: pull_request
5463
allow_forks: true
64+
65+
66+
# We use a wildcard (*) because the artifact name from the build workflow
67+
# contains a dynamic commit SHA (e.g., vscode-reh-web-linux-x64-0.0.0-dev-...).
5568
name: npm-package
69+
# The path where the downloaded artifact will be saved.
5670
path: ./release-assets
71+
# Ensure we only get the artifact from a successful run.
5772
workflow_conclusion: success
5873

59-
# Step 4: Rename the artifact to a standardized release filename
74+
# Step 3: Prepare the release assets by renaming the artifact.
75+
# This takes the downloaded file and gives it a clean, versioned name.
6076
- name: Prepare release assets
6177
id: prepare_assets
6278
run: |
79+
# Find the downloaded tarball (there should only be one).
6380
ARTIFACT_FILE=$(find ./release-assets -name "*.tar.gz")
81+
6482
if [ -z "$ARTIFACT_FILE" ]; then
6583
echo "::error::Build artifact not found in ./release-assets! Make sure the 'Build' workflow ran successfully on the '${{ github.event.inputs.source_branch }}' branch."
6684
exit 1
6785
fi
86+
87+
# Get the version from the manual input, and remove the leading 'v' if it exists.
6888
VERSION_TAG="${{ github.event.inputs.version }}"
6989
VERSION_NUM="${VERSION_TAG#v}"
90+
91+
# Create the new, clean filename for the release.
92+
# This is the standardized name that your conda-forge recipe will expect.
7093
NEW_FILENAME="code-editor${VERSION_NUM}.tar.gz"
94+
95+
# Rename the file.
7196
mv "$ARTIFACT_FILE" "./release-assets/$NEW_FILENAME"
97+
7298
echo "Renamed artifact to $NEW_FILENAME"
99+
# Set the new filename as an output for the next step.
73100
echo "filename=./release-assets/$NEW_FILENAME" >> $GITHUB_OUTPUT
74-
75-
# Step 5: Create the release and upload the asset, also create the tag
76-
# This step will generate release notes, tag, and ensure all times match
101+
# Step 4: Create the GitHub Release and upload the prepared asset.
102+
# This action creates the tag, the release, and uploads your .tar.gz file.
77103
- name: Create GitHub Release
78104
uses: softprops/action-gh-release@v2
79105
with:
106+
# The name of the release, e.g., "Release v1.8.0".
80107
name: CodeEditor ${{ github.event.inputs.version }}
108+
# The Git tag to create, e.g., "v1.8.0".
81109
tag_name: ${{ github.event.inputs.version }}
110+
# Path to the file(s) to upload as release assets.
82111
files: ${{ steps.prepare_assets.outputs.filename }}
112+
# Set to 'false' to publish immediately, or 'true' to create a draft.
83113
draft: false
84-
generate_release_notes: true
114+
# Automatically generate release notes from commits since the last release.
115+
generate_release_notes: false
116+

0 commit comments

Comments
 (0)