-
Notifications
You must be signed in to change notification settings - Fork 1
224 lines (182 loc) · 6.38 KB
/
Copy pathbuild-and-publish.yaml
File metadata and controls
224 lines (182 loc) · 6.38 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build and Publish
on:
push:
branches:
- '*'
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
name: Lint and typecheck
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Setup Node.js with corepack
uses: ./.github/actions/setup-node
- name: Setup cache
uses: ./.github/actions/setup-cache
with:
restore-key-prefix: 'lint-cache'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run typecheck
run: pnpm run check-types
- name: Run linting
run: pnpm run lint
test:
name: Run tests
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Setup Node.js with corepack
uses: ./.github/actions/setup-node
- name: Setup cache
uses: ./.github/actions/setup-cache
with:
restore-key-prefix: 'test-cache'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a pnpm run test
- name: Run tests (non-Linux)
if: runner.os != 'Linux'
run: pnpm run test
build:
runs-on: ubuntu-latest
name: Build extension
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Setup Node.js with corepack
uses: ./.github/actions/setup-node
- name: Setup cache
uses: ./.github/actions/setup-cache
with:
restore-key-prefix: 'build-cache'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build extension
run: pnpm run package
- name: Validate package version
run: |
PACKAGE_VERSION=$(jq -r '.version' package.json)
MINOR_VERSION=$(echo "$PACKAGE_VERSION" | cut -d. -f2)
if [ $((MINOR_VERSION % 2)) -ne 0 ]; then
echo "Error: Minor version must be even. Current version: $PACKAGE_VERSION"
echo "::error title=Minor version must be even::Minor version in package.json must be even. Current version: $PACKAGE_VERSION"
exit 1
fi
echo "Version validation passed: $PACKAGE_VERSION"
- name: Set version for packaging
id: version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
PACKAGE_VERSION=$(jq -r '.version' package.json)
VERSION="${PACKAGE_VERSION}"
else
PACKAGE_VERSION=$(jq -r '.version' package.json)
MAJOR=$(echo "$PACKAGE_VERSION" | cut -d. -f1)
MINOR=$(echo "$PACKAGE_VERSION" | cut -d. -f2)
NEXT_MINOR=$((MINOR + 1))
# Use GitHub run number for guaranteed increment
PATCH="${{ github.run_number }}"
VERSION="${MAJOR}.${NEXT_MINOR}.${PATCH}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Package extension (Pre-release)
if: github.ref_type != 'tag'
run: |
# Temporarily update package.json version for pre-release packaging
jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
pnpm vsce package --no-dependencies --pre-release --out "package-navigator-${{ steps.version.outputs.version }}.vsix"
echo "📦 Build type: Pre-release" >> $GITHUB_STEP_SUMMARY
echo "🚀 Version: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
- name: Package extension (Release)
if: github.ref_type == 'tag'
run: |
pnpm vsce package --no-dependencies --out "package-navigator-${{ steps.version.outputs.version }}.vsix"
echo "📦 Build type: Release" >> $GITHUB_STEP_SUMMARY
echo "🚀 Version: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: vscode-extension
path: '*.vsix'
publish-ovsx:
if: github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref == 'refs/heads/main')
needs:
- lint
- test
- build
runs-on: ubuntu-latest
name: Publish to Open VSX
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Enable corepack
shell: bash
run: corepack enable
- name: Prepare pnpm
shell: bash
run: |
corepack prepare pnpm@latest --activate
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
- name: Install ovsx CLI
run: pnpm add -g ovsx --dangerously-allow-all-builds
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: vscode-extension
- name: Publish to Open VSX
run: ovsx publish --packagePath *.vsix --pat ${{ secrets.OVSX_TOKEN }}
publish-vsce:
if: github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref == 'refs/heads/main')
needs:
- lint
- test
- build
runs-on: ubuntu-latest
name: Publish to VS Code Marketplace
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Enable corepack
shell: bash
run: corepack enable
- name: Prepare pnpm
shell: bash
run: |
corepack prepare pnpm@latest --activate
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
- name: Install vsce CLI
run: pnpm add -g vsce --dangerously-allow-all-builds
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: vscode-extension
- name: Publish to VS Code Marketplace
run: vsce publish --packagePath *.vsix --pat ${{ secrets.VSCE_TOKEN }}