forked from icy-r/package-json-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (123 loc) · 4 KB
/
Copy pathci-cd.yml
File metadata and controls
151 lines (123 loc) · 4 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
name: CI/CD Pipeline
on:
push:
branches: [main, master]
tags:
- "v*"
pull_request:
branches: [main, master]
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Compile
run: pnpm run compile
- name: Compile Tests
run: pnpm run test-compile
- name: Copy Test Runner
run: |
mkdir -p out/test
cp src/test/runTest.js out/test/
- name: Run Tests
uses: GabrielBB/xvfb-action@v1
with:
run: pnpm run test
working-directory: ${{ github.workspace }}
- name: Package Extension
run: pnpm run package
- name: Package VSIX
run: pnpm dlx vsce package --no-dependencies
- name: Upload VSIX Artifact
uses: actions/upload-artifact@v4
with:
name: package-json-manager-vsix
path: "*.vsix"
if-no-files-found: error
release:
name: Release to Marketplace & GitHub
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
# Add permissions needed for creating releases
permissions:
contents: write
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Download VSIX Artifact
uses: actions/download-artifact@v4
with:
name: package-json-manager-vsix
- name: Get VSIX file name
id: vsix-name
run: echo "VSIX_NAME=$(ls *.vsix)" >> $GITHUB_OUTPUT
- name: Get Version from Tag
id: get-version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Verify Package Version
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "v$PKG_VERSION" != "${{ github.ref_name }}" ]; then
echo "Error: Tag version (${{ github.ref_name }}) does not match package.json version (v$PKG_VERSION)"
exit 1
fi
- name: Publish to Visual Studio Marketplace
run: pnpm dlx vsce publish --packagePath ${{ steps.vsix-name.outputs.VSIX_NAME }}
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Create GitHub Release
id: create-release
uses: softprops/action-gh-release@v1
with:
name: Release v${{ steps.get-version.outputs.VERSION }}
files: ${{ steps.vsix-name.outputs.VSIX_NAME }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}