forked from ttiimm/log2src
-
Notifications
You must be signed in to change notification settings - Fork 0
274 lines (233 loc) · 8.61 KB
/
main.yml
File metadata and controls
274 lines (233 loc) · 8.61 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: Build & Release
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
lib-build-and-test:
name: Build & Test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
# ensures each build runs even if one fails
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: log2src
asset_name: log2src-${{ github.ref_name }}-linux-x64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: log2src
asset_name: log2src-${{ github.ref_name }}-macos-x64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: log2src
asset_name: log2src-${{ github.ref_name }}-macos-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: log2src.exe
asset_name: log2src-${{ github.ref_name }}-windows-x64
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Setup cross-compilation for ARM64
if: matrix.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Build release binary for extension tests (macOS ARM64 only)
if: matrix.target == 'aarch64-apple-darwin'
run: cargo build --release --target ${{ matrix.target }}
- name: Upload release binary for extension tests (macOS ARM64 only)
if: matrix.target == 'aarch64-apple-darwin'
uses: actions/upload-artifact@v4
with:
name: log2src-test-binary
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
if-no-files-found: error
vscode-extension-test:
name: Test VS Code Extension
needs: [lib-build-and-test]
runs-on: macos-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download log2src binary
uses: actions/download-artifact@v4
with:
name: log2src-test-binary
path: downloaded-binary
- name: Setup binary for VS Code extension
run: |
mkdir -p editors/code/bin/darwin-arm64
cp downloaded-binary/log2src editors/code/bin/darwin-arm64/
chmod +x editors/code/bin/darwin-arm64/log2src
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.8.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: 'editors/code/pnpm-lock.yaml'
- name: Install Dependencies
working-directory: editors/code
run: pnpm install
- name: Run tests
working-directory: editors/code
run: pnpm run test
build-release:
name: Build Release
needs: [lib-build-and-test]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
# ensures each build runs even if one fails
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: log2src
asset_name: log2src-${{ github.ref_name }}-linux-x64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: log2src
asset_name: log2src-${{ github.ref_name }}-macos-x64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: log2src
asset_name: log2src-${{ github.ref_name }}-macos-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: log2src.exe
asset_name: log2src-${{ github.ref_name }}-windows-x64
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Setup cross-compilation for ARM64
if: matrix.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package binary (Unix)
if: matrix.os != 'windows-latest'
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/
cd release && tar -czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
- name: Package binary (Windows)
if: matrix.os == 'windows-latest'
run: |
mkdir -p release
copy target\${{ matrix.target }}\release\${{ matrix.artifact_name }} release\
cd release && 7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: release/${{ matrix.asset_name }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
if-no-files-found: error
vscode-extension:
name: Build VS Code Extensions
needs: [build-release]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.8.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: 'editors/code/pnpm-lock.yaml'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Extract binaries for VS Code extension
run: |
mkdir -p editors/code/bin/{linux-x64,darwin-x64,darwin-arm64,win32-x64}
tar -xzf artifacts/log2src-${{ github.ref_name }}-linux-x64/log2src-${{ github.ref_name }}-linux-x64.tar.gz -C editors/code/bin/linux-x64
tar -xzf artifacts/log2src-${{ github.ref_name }}-macos-x64/log2src-${{ github.ref_name }}-macos-x64.tar.gz -C editors/code/bin/darwin-x64
tar -xzf artifacts/log2src-${{ github.ref_name }}-macos-arm64/log2src-${{ github.ref_name }}-macos-arm64.tar.gz -C editors/code/bin/darwin-arm64
unzip -o artifacts/log2src-${{ github.ref_name }}-windows-x64/log2src-${{ github.ref_name }}-windows-x64.zip -d editors/code/bin/win-x64
- name: Install Dependencies
working-directory: editors/code
run: pnpm install
- name: Run tests (Linux)
working-directory: editors/code
if: runner.os == 'Linux'
run: |
sudo apt-get install -y xvfb
pnpm run test:ci
- name: Run Tests (Osx/Windows)
working-directory: editors/code
if: runner.os != 'Linux'
run: pnpm run test
- name: Build VS Code extension
if: startsWith(github.ref, 'refs/tags/')
working-directory: editors/code
run: |
REF_NAME="${{ github.ref_name }}"
VERSION=${REF_NAME#v}
# Update version in package.json
jq '.version = "'$VERSION'"' package.json > package.json.new
mv package.json.new package.json
pnpm vsce package --no-dependencies
- name: Upload VS Code extension
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: log2src-ext-${{ github.ref_name }}.vsix
path: editors/code/log2src-ext-*.vsix
if-no-files-found: error
release:
name: Create Release
needs: [build-release, vscode-extension]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release
- name: List files
run: ls -R release
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: log2src ${{ github.ref_name }}
token: ${{ secrets.L2S_RELEASE }}
files: release/**/*
draft: true
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }}