generated from tjx666/awesome-vscode-extension-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (90 loc) · 2.82 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: 🏃 CI
permissions:
contents: write
on:
push:
branches:
- main
jobs:
test:
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.os }}
outputs:
GIT_TAG: ${{ steps.set-tag.outputs.GIT_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Get the date on Ubuntu/MacOS
id: date_unix
if: runner.os != 'Windows'
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Get the date on Windows
id: date_windows
if: runner.os == 'Windows'
run: echo "DATE=$(Get-Date -Format 'yyyyMMdd')" >> $GITHUB_OUTPUT
- name: Cache .vscode-test
uses: actions/cache@v4
env:
# we use date as part of key because the vscode insiders updated daily
CACHE_PREFIX: ${{ runner.os }}-vscode-test-${{ steps.date_unix.outputs.DATE || steps.date_windows.outputs.DATE }}
with:
path: .vscode-test
key: ${{ env.CACHE_PREFIX }}-${{ hashFiles('test/runTests.ts') }}
restore-keys: ${{ env.CACHE_PREFIX }}
- run: xvfb-run -a pnpm test
if: runner.os == 'Linux'
- run: pnpm test
if: runner.os != 'Linux'
- name: Set GIT_TAG
id: set-tag
if: runner.os == 'Linux'
run: |
git fetch --tags origin
GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$GIT_TAG" ] && [ "$(git rev-list -n 1 $GIT_TAG 2>/dev/null || echo "")" = "$(git rev-parse HEAD)" ]; then
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
else
echo "GIT_TAG=''" >> $GITHUB_OUTPUT
fi
publish:
needs: test
if: startsWith(needs.test.outputs.GIT_TAG, 'v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
name: Install pnpm
- name: Install Node.js
uses: actions/setup-node@v4
with:
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Publish to Visual Studio Marketplace
run: pnpm run publish:vs-marketplace
env:
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }}
# - name: Publish to Open VSX Registry
# run: pnpm run publish:open-vsx -p ${{ secrets.OPEN_VSX_TOKEN }}
- name: Github Release
run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}