Repository navigation
210 lines (182 loc) · 6.81 KB
/
Copy pathrelease.yml
File metadata and controls
210 lines (182 loc) · 6.81 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
name: Release & Multi-Platform Native CI
on:
push:
tags:
- 'v*.*.*-pre*'
- 'v*.*.*'
workflow_dispatch:
inputs:
publish_marketplace:
description: 'Publish to Visual Studio Code Marketplace'
required: true
type: boolean
default: false
pre_release:
description: 'Publish as Pre-Release version (uncheck for Stable)'
required: true
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
env:
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: "node24"
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-and-package:
name: Build & Package (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: win32-x64
rust_target: x86_64-pc-windows-msvc
binary_name: c_cpp_pro_native.dll
- os: ubuntu-latest
target: linux-x64
rust_target: x86_64-unknown-linux-gnu
binary_name: libc_cpp_pro_native.so
- os: macos-latest
target: darwin-arm64
rust_target: aarch64-apple-darwin
binary_name: libc_cpp_pro_native.dylib
- os: macos-15-intel
target: darwin-x64
rust_target: x86_64-apple-darwin
binary_name: libc_cpp_pro_native.dylib
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine Release Mode (Pre-Release vs Stable)
id: release_mode
shell: bash
run: |
IS_PRE="false"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ "${{ inputs.pre_release }}" = "true" ]; then
IS_PRE="true"
fi
elif [[ "${{ github.ref }}" == *"-pre"* ]]; then
IS_PRE="true"
else
# VS Code Marketplace SemVer convention: odd minor version = pre-release, even = stable
VERSION=$(node -p "require('./package.json').version")
MINOR=$(echo "$VERSION" | cut -d. -f2)
if [ $((MINOR % 2)) -ne 0 ]; then
IS_PRE="true"
fi
fi
echo "is_pre_release=$IS_PRE" >> "$GITHUB_OUTPUT"
echo "Release Channel: $([ "$IS_PRE" = "true" ] && echo "Pre-Release" || echo "Stable Release")"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'
cache: 'npm'
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install Node dependencies
run: npm ci
- name: Run TypeScript type check
run: npm run check-types
- name: Build Rust native addon (${{ matrix.rust_target }})
working-directory: crates/c-cpp-pro-native
run: cargo build --release --target ${{ matrix.rust_target }}
- name: Test Rust native addon
working-directory: crates/c-cpp-pro-native
run: cargo test
- name: Deploy native binary into extension bundle
shell: bash
run: |
mkdir -p native/${{ matrix.target }}
mkdir -p native
CANDIDATES=(
"target/${{ matrix.rust_target }}/release/${{ matrix.binary_name }}"
"crates/c-cpp-pro-native/target/${{ matrix.rust_target }}/release/${{ matrix.binary_name }}"
"target/release/${{ matrix.binary_name }}"
"crates/c-cpp-pro-native/target/release/${{ matrix.binary_name }}"
)
FOUND=""
for p in "${CANDIDATES[@]}"; do
if [ -f "$p" ]; then
FOUND="$p"
break
fi
done
if [ -n "$FOUND" ]; then
cp "$FOUND" native/c_cpp_pro_native.node
cp "$FOUND" native/${{ matrix.target }}/c_cpp_pro_native.node
echo "Successfully staged native binary: $FOUND -> native/c_cpp_pro_native.node and native/${{ matrix.target }}/c_cpp_pro_native.node"
ls -lh native/c_cpp_pro_native.node native/${{ matrix.target }}/c_cpp_pro_native.node
else
echo "Error: Native binary not found. Searched in:"
printf ' %s\n' "${CANDIDATES[@]}"
echo "Searching filesystem for compiled native binary:"
find target crates/c-cpp-pro-native/target -name "*c_cpp_pro_native*" || true
exit 1
fi
- name: Build extension bundle (esbuild)
env:
SKIP_NATIVE_BUILD: "1"
run: npm run build
- name: Run unit test suite
run: npm test
- name: Package platform-specific VSIX
shell: bash
run: |
PRE_FLAG=""
if [ "${{ steps.release_mode.outputs.is_pre_release }}" = "true" ]; then
PRE_FLAG="--pre-release"
fi
npx @vscode/vsce package --target ${{ matrix.target }} $PRE_FLAG --no-dependencies
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: c-cpp-pro-${{ matrix.target }}
path: '*.vsix'
retention-days: 14
- name: Publish to Visual Studio Code Marketplace
if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || inputs.publish_marketplace }}
env:
VSCE_PAT: ${{ secrets.VSCE_PAT || secrets.VSCODE_MARKETPLACE_TOKEN || secrets.MARKETPLACE_PAT || secrets.VSCE_TOKEN }}
shell: bash
run: |
if [ -z "$VSCE_PAT" ]; then
echo "VSCE_PAT secret is not configured. Skipping marketplace publication."
else
VSIX_FILE=$(ls *.vsix | head -n 1)
echo "Publishing platform package $VSIX_FILE to Visual Studio Code Marketplace..."
npx @vscode/vsce publish --packagePath "$VSIX_FILE" --pat "$VSCE_PAT" --skip-duplicate
fi
github-release:
name: Create GitHub Release
needs: build-and-package
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all packaged VSIX artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Consolidate VSIX files
shell: bash
run: |
mkdir -p release-vsix
find artifacts -type f -name "*.vsix" -exec cp {} release-vsix/ \;
ls -la release-vsix/
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release-vsix/*.vsix
prerelease: ${{ contains(github.ref, '-pre') }}
generate_release_notes: true