Skip to content

Commit f82343a

Browse files
Danverrserafimcloud
authored andcommitted
edit publish workflow
1 parent 8f402f2 commit f82343a

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,35 @@ jobs:
5353
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5454
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_ACCESS_TOKEN }} # Ensure secret name is correct
5555

56-
- name: Check for VSCode Extension Version Change and Release
57-
# This step runs after changesets/action has committed the version bump
56+
- name: Check for VSCode Extension Version and Release if Not Released
57+
# This step checks if the current version from package.json is already released
5858
run: |
59-
# Get the SHA of the commit made by changesets/action (should be HEAD)
60-
RELEASE_COMMIT_SHA=$(git rev-parse HEAD)
61-
echo "Checking for changes to VSCode extension in commit $RELEASE_COMMIT_SHA"
62-
63-
# Check if the specific package.json was changed in this commit compared to its parent
64-
# Use exit code: 0 = no changes, 1 = changes.
65-
# Use git diff-tree to check files changed in the commit.
66-
# The `!` negates the exit code, so the block executes if grep finds the file (exit code 0 -> !0 -> true)
67-
if ! git diff-tree --no-commit-id --name-only -r $RELEASE_COMMIT_SHA | grep -q "^apps/vscode-extension/package.json$"; then
68-
echo "VSCode extension package.json not modified in this release commit. Skipping VSCode extension release."
69-
echo "VSCODE_EXTENSION_CHANGED=false" >> $GITHUB_ENV
70-
exit 0 # Exit successfully, no release needed
71-
fi
72-
73-
echo "VSCode extension package.json was modified. Proceeding with VSCode extension release."
74-
echo "VSCODE_EXTENSION_CHANGED=true" >> $GITHUB_ENV
75-
76-
# Read the new version directly from the package.json at the release commit
77-
# Ensure we're in the workspace root for pnpm filter to work correctly
78-
cd $GITHUB_WORKSPACE
59+
# Read the current version from package.json
60+
cd $GITHUB_WORKSPACE
7961
VERSION=$(pnpm --filter 21st-extension exec node -p "require('./package.json').version")
8062
8163
if [ -z "$VERSION" ]; then
8264
echo "Error: Could not read version from apps/vscode-extension/package.json"
8365
exit 1 # Exit with error
8466
fi
8567
68+
echo "Current VSCode extension version: $VERSION"
69+
TAG_NAME="21st-extension@$VERSION"
70+
71+
# Check if this version tag already exists
72+
if git tag -l | grep -q "^$TAG_NAME$"; then
73+
echo "Version $VERSION is already released (tag $TAG_NAME exists). Skipping VSCode extension release."
74+
echo "VSCODE_EXTENSION_CHANGED=false" >> $GITHUB_ENV
75+
exit 0 # Exit successfully, no release needed
76+
fi
77+
78+
echo "Version $VERSION is not yet released (tag $TAG_NAME does not exist). Proceeding with VSCode extension release."
79+
echo "VSCODE_EXTENSION_CHANGED=true" >> $GITHUB_ENV
80+
8681
# Store version for subsequent steps
8782
echo "VSCODE_EXTENSION_VERSION=$VERSION" >> $GITHUB_ENV
8883
echo "VSIX_FILENAME=21st-extension-$VERSION.vsix" >> $GITHUB_ENV
89-
echo "TAG_NAME=21st-extension@$VERSION" >> $GITHUB_ENV
84+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
9085
env:
9186
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9287

0 commit comments

Comments
 (0)