1+ name : VSCode Extension
2+
3+ on :
4+ push :
5+ tags :
6+ - ' extension-v*'
7+ workflow_dispatch :
8+
9+ jobs :
10+ build-cli :
11+ uses : ./.github/workflows/build.yml
12+ with :
13+ artifacts-for-extension : true
14+
15+ build-extension :
16+ needs : build-cli
17+ runs-on : ubuntu-latest
18+ steps :
19+ - name : Checkout
20+ uses : actions/checkout@v4
21+
22+ - name : Setup Node.js
23+ uses : actions/setup-node@v4
24+ with :
25+ node-version : 20.x
26+ cache : ' npm'
27+
28+ - name : Setup PNPM
29+ uses : pnpm/action-setup@v2
30+ with :
31+ version : 8
32+ run_install : false
33+
34+ - name : Get pnpm store directory
35+ shell : bash
36+ run : |
37+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
38+
39+ - name : Setup pnpm cache
40+ uses : actions/cache@v3
41+ with :
42+ path : ${{ env.STORE_PATH }}
43+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44+ restore-keys : |
45+ ${{ runner.os }}-pnpm-store-
46+
47+ - name : Install dependencies
48+ run : cd vscode-rescriptdep && pnpm install
49+
50+ - name : Create temp and bin directories
51+ run : |
52+ mkdir -p temp/darwin temp/linux temp/win32
53+ mkdir -p vscode-rescriptdep/bin/darwin
54+ mkdir -p vscode-rescriptdep/bin/linux
55+ mkdir -p vscode-rescriptdep/bin/win32
56+
57+ - name : Download macOS CLI artifact
58+ uses : actions/download-artifact@v3
59+ with :
60+ name : rescriptdep-darwin-x64-latest
61+ path : temp/darwin
62+
63+ - name : Download Linux CLI artifact
64+ uses : actions/download-artifact@v3
65+ with :
66+ name : rescriptdep-linux-x64-latest
67+ path : temp/linux
68+
69+ - name : Download Windows CLI artifact
70+ uses : actions/download-artifact@v3
71+ with :
72+ name : rescriptdep-win32-x64-latest
73+ path : temp/win32
74+
75+ - name : Extract CLI binaries and move to extension bin folders
76+ run : |
77+ # Extract macOS binary
78+ tar -xzf temp/darwin/rescriptdep-darwin-x64-latest.tar.gz -C temp/darwin
79+ cp temp/darwin/rescriptdep vscode-rescriptdep/bin/darwin/
80+
81+ # Extract Linux binary
82+ tar -xzf temp/linux/rescriptdep-linux-x64-latest.tar.gz -C temp/linux
83+ cp temp/linux/rescriptdep vscode-rescriptdep/bin/linux/
84+
85+ # Extract Windows binary
86+ unzip -j temp/win32/rescriptdep-win32-x64-latest.zip -d temp/win32
87+ cp temp/win32/rescriptdep.exe vscode-rescriptdep/bin/win32/
88+
89+ - name : Set executable permissions
90+ run : |
91+ chmod +x vscode-rescriptdep/bin/darwin/rescriptdep
92+ chmod +x vscode-rescriptdep/bin/linux/rescriptdep
93+
94+ - name : Lint
95+ run : cd vscode-rescriptdep && pnpm run lint
96+
97+ - name : Type Check
98+ run : cd vscode-rescriptdep && pnpm run check-types
99+
100+ - name : Build
101+ run : cd vscode-rescriptdep && pnpm run package
102+
103+ - name : Get Extension Version
104+ id : get_version
105+ run : |
106+ VERSION=$(node -p "require('./vscode-rescriptdep/package.json').version")
107+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
108+
109+ - name : Create VSIX Package
110+ run : |
111+ cd vscode-rescriptdep
112+ npm install -g @vscode/vsce
113+ vsce package
114+
115+ - name : Upload VSIX as Artifact
116+ uses : actions/upload-artifact@v3
117+ with :
118+ name : vscode-rescriptdep-${{ steps.get_version.outputs.VERSION }}
119+ path : vscode-rescriptdep/vscode-rescriptdep-${{ steps.get_version.outputs.VERSION }}.vsix
120+ retention-days : 7
121+
122+ publish :
123+ runs-on : ubuntu-latest
124+ needs : build-extension
125+ steps :
126+ - name : Checkout
127+ uses : actions/checkout@v4
128+
129+ - name : Setup Node.js
130+ uses : actions/setup-node@v4
131+ with :
132+ node-version : 20.x
133+
134+ - name : Get Extension Version
135+ id : get_version
136+ run : |
137+ VERSION=$(node -p "require('./vscode-rescriptdep/package.json').version")
138+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
139+
140+ - name : Download VSIX Artifact
141+ uses : actions/download-artifact@v3
142+ with :
143+ name : vscode-rescriptdep-${{ steps.get_version.outputs.VERSION }}
144+ path : ./
145+
146+ - name : Publish to VS Code Marketplace
147+ run : |
148+ npm install -g @vscode/vsce
149+ vsce publish -p ${{ secrets.VSCE_PAT }} --packagePath vscode-rescriptdep-${{ steps.get_version.outputs.VERSION }}.vsix
150+ env :
151+ VSCE_PAT : ${{ secrets.VSCE_PAT }}
152+
153+ # - name: Publish to Open VSX Registry
154+ # run: |
155+ # npm install -g ovsx
156+ # ovsx publish vscode-rescriptdep-${{ steps.get_version.outputs.VERSION }}.vsix -p ${{ secrets.OVSX_PAT }}
157+ # env:
158+ # OVSX_PAT: ${{ secrets.OVSX_PAT }}
0 commit comments