77 workflow_dispatch : # Allow manual trigger
88
99jobs :
10+ verify-changes :
11+ runs-on : ubuntu-latest
12+ outputs :
13+ should_publish : ${{ steps.check-changes.outputs.should_publish }}
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0 # Fetch all history for all tags and branches
20+
21+ - name : Get changed files
22+ id : changed-files
23+ run : |
24+ echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | tr '\n' ' ')" >> $GITHUB_OUTPUT
25+
26+ - name : Check version change and file types
27+ id : check-changes
28+ run : |
29+ # Check if package.json version changed
30+ VERSION_CHANGED=$(git diff ${{ github.event.before }} ${{ github.event.after }} package.json | grep '+\s*"version"')
31+
32+ # Get list of changed files
33+ CHANGED_FILES="${{ steps.changed-files.outputs.files }}"
34+
35+ # Check if only documentation files were changed
36+ DOCS_ONLY=true
37+ for file in $CHANGED_FILES; do
38+ if [[ ! $file =~ \.(md|txt|doc|docx)$ ]] && [[ ! $file =~ ^docs/ ]]; then
39+ DOCS_ONLY=false
40+ break
41+ fi
42+ done
43+
44+ # Initialize should_publish as false
45+ echo "should_publish=false" >> $GITHUB_OUTPUT
46+
47+ if [[ "$DOCS_ONLY" == "true" ]]; then
48+ echo "ℹ️ Only documentation files were changed"
49+ echo "should_publish=false" >> $GITHUB_OUTPUT
50+ elif [[ -z "$VERSION_CHANGED" ]]; then
51+ echo "❌ Version in package.json was not updated"
52+ echo "should_publish=false" >> $GITHUB_OUTPUT
53+ else
54+ echo "✅ Version changed and non-documentation files modified"
55+ echo "should_publish=true" >> $GITHUB_OUTPUT
56+ fi
57+
1058 publish :
59+ needs : verify-changes
60+ if : needs.verify-changes.outputs.should_publish == 'true'
1161 runs-on : ubuntu-latest
12- environment : VSC EXT # Specify the environment where the secret is stored
62+ environment : VSC EXT
1363
1464 steps :
1565 - name : Checkout code
3383 run : vsce package
3484
3585 - name : Publish to Visual Studio Marketplace
36- run : vsce publish -p "${{ secrets.VSC_PAT }}"
86+ run : vsce publish -p "${{ secrets.VSC_PAT }}"
0 commit comments