forked from windup/rhamt-vscode-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 2.57 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Basic CI
on:
push:
branches:
- "master" # Trigger only on pushes to the master branch
pull_request:
branches:
- "master" # Trigger on pull requests targeting the master branch
release:
types:
- created # Run when a new release is created
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest # Use Ubuntu for the runner
steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "16" # Specify the Node.js version
# Step 3: Install dependencies
- name: Install dependencies
run: npm install
# Step 4: Compile the project
- name: Compile the project
run: npm run compile
publish:
name: Package & Upload VSIX (Fake Publish in Fork, Real in Main)
runs-on: ubuntu-latest
needs: test # Ensure tests pass before publishing
if: github.event_name == 'release' # Ensure it only runs on a new release
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
- name: Install vsce (VS Code Extension Manager)
run: npm install -g @vscode/vsce
- name: Install Dependencies
run: npm install
- name: Build Extension
run: npm run compile # Change if needed
# Step 5: Package the VSIX file and ensure "dist" directory exists
- name: Package the VSIX file
run: |
mkdir -p dist # Create the dist folder if it doesn't exist
vsce package -o dist/extension.vsix # Generate the VSIX file in "dist/"
# Step 6: Debugging Step - List dist directory
- name: Debug: List dist directory
run: ls -la dist/
# Step 7: Upload VSIX file as an artifact
- name: Upload VSIX Artifact
uses: actions/upload-artifact@v4
with:
name: vscode-extension
path: dist/*.vsix
# Step 8: Fake Publish on Fork, Real Publish on Main
- name: Fake Publish (If Fork) or Real Publish
env:
IS_FORK: ${{ github.repository_owner == 'hhpatel14' }}
run: |
echo "Checking if this is a fork..."
if [ "$IS_FORK" = "true" ]; then
echo "This is a fork. Running fake publish..."
else
echo "This is the main repo. Publishing to VS Code Marketplace..."
vsce publish --pat ${{ secrets.VSCE_TOKEN }}
fi