Skip to content

Commit a3b8eb3

Browse files
committed
github actions
1 parent 4dfb089 commit a3b8eb3

File tree

2 files changed

+290
-0
lines changed

2 files changed

+290
-0
lines changed

.github/workflows/build.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Build CLI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- 'cli-v*'
8+
pull_request:
9+
branches: [ main ]
10+
workflow_dispatch:
11+
workflow_call:
12+
inputs:
13+
artifacts-for-extension:
14+
required: false
15+
type: boolean
16+
default: false
17+
18+
jobs:
19+
build-macos:
20+
runs-on: macos-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up OCaml
24+
uses: ocaml/setup-ocaml@v2
25+
with:
26+
ocaml-compiler: 5.3.0
27+
dune-cache: true
28+
- name: Get version
29+
id: get_version
30+
run: |
31+
if [[ $GITHUB_REF == refs/tags/cli-v* ]]; then
32+
echo "VERSION=${GITHUB_REF#refs/tags/cli-v}" >> $GITHUB_OUTPUT
33+
else
34+
echo "VERSION=latest" >> $GITHUB_OUTPUT
35+
fi
36+
- name: Install dependencies
37+
run: opam install . --deps-only --with-test
38+
- name: Build project
39+
run: opam exec -- dune build
40+
- name: Create executable directory
41+
run: mkdir -p dist
42+
- name: Copy executable
43+
run: cp _build/default/bin/main.exe dist/rescriptdep
44+
- name: Set executable permissions
45+
run: chmod +x dist/rescriptdep
46+
- name: Create tar archive
47+
run: |
48+
cd dist
49+
tar -czf rescriptdep-darwin-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz rescriptdep
50+
- name: Upload artifact
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: rescriptdep-darwin-x64-${{ steps.get_version.outputs.VERSION }}
54+
path: dist/rescriptdep-darwin-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz
55+
retention-days: 7
56+
57+
build-linux:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
- name: Set up OCaml
62+
uses: ocaml/setup-ocaml@v2
63+
with:
64+
ocaml-compiler: 5.3.0
65+
dune-cache: true
66+
- name: Get version
67+
id: get_version
68+
run: |
69+
if [[ $GITHUB_REF == refs/tags/cli-v* ]]; then
70+
echo "VERSION=${GITHUB_REF#refs/tags/cli-v}" >> $GITHUB_OUTPUT
71+
else
72+
echo "VERSION=latest" >> $GITHUB_OUTPUT
73+
fi
74+
- name: Install dependencies
75+
run: opam install . --deps-only --with-test
76+
- name: Build project
77+
run: opam exec -- dune build
78+
- name: Create executable directory
79+
run: mkdir -p dist
80+
- name: Copy executable
81+
run: cp _build/default/bin/main.exe dist/rescriptdep
82+
- name: Set executable permissions
83+
run: chmod +x dist/rescriptdep
84+
- name: Create tar archive
85+
run: |
86+
cd dist
87+
tar -czf rescriptdep-linux-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz rescriptdep
88+
- name: Upload artifact
89+
uses: actions/upload-artifact@v3
90+
with:
91+
name: rescriptdep-linux-x64-${{ steps.get_version.outputs.VERSION }}
92+
path: dist/rescriptdep-linux-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz
93+
retention-days: 7
94+
95+
build-windows:
96+
runs-on: windows-latest
97+
steps:
98+
- uses: actions/checkout@v4
99+
- name: Set up OCaml
100+
uses: ocaml/setup-ocaml@v2
101+
with:
102+
ocaml-compiler: 5.3.0
103+
dune-cache: true
104+
- name: Get version
105+
id: get_version
106+
shell: bash
107+
run: |
108+
if [[ $GITHUB_REF == refs/tags/cli-v* ]]; then
109+
echo "VERSION=${GITHUB_REF#refs/tags/cli-v}" >> $GITHUB_OUTPUT
110+
else
111+
echo "VERSION=latest" >> $GITHUB_OUTPUT
112+
fi
113+
- name: Install dependencies
114+
run: opam install . --deps-only --with-test
115+
- name: Build project
116+
run: opam exec -- dune build
117+
- name: Create executable directory
118+
run: mkdir -p dist
119+
- name: Copy executable
120+
shell: bash
121+
run: cp _build/default/bin/main.exe dist/rescriptdep.exe
122+
- name: Create zip archive
123+
shell: bash
124+
run: |
125+
cd dist
126+
7z a rescriptdep-win32-x64-${{ steps.get_version.outputs.VERSION }}.zip rescriptdep.exe
127+
- name: Upload artifact
128+
uses: actions/upload-artifact@v3
129+
with:
130+
name: rescriptdep-win32-x64-${{ steps.get_version.outputs.VERSION }}
131+
path: dist/rescriptdep-win32-x64-${{ steps.get_version.outputs.VERSION }}.zip
132+
retention-days: 7
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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

Comments
 (0)