-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (107 loc) · 3.46 KB
/
release.yml
File metadata and controls
128 lines (107 loc) · 3.46 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
build:
name: Build VSIX
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
run: npm ci
- name: Build extension
run: npm run compile
- name: Package VSIX
run: npm run vsix
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: vsix
path: "*.vsix"
retention-days: 90
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download VSIX artifact
uses: actions/download-artifact@v4
with:
path: ./vsix-artifacts
- name: Extract version
id: version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
- name: Verify version match
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION="${{ steps.version.outputs.version }}"
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "Error: package.json ($PACKAGE_VERSION) != tag ($TAG_VERSION)"
exit 1
fi
- name: Generate changelog
run: |
PREVIOUS_TAG=$(git describe --abbrev=0 --tags "$(git rev-list --tags --skip=1 --max-count=1)" 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD)
fi
CURRENT_TAG="${GITHUB_REF_NAME}"
git log "$PREVIOUS_TAG".."$CURRENT_TAG" --pretty=format:"* %s (%h)" --no-merges > CHANGELOG.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.version.outputs.version }}
body_path: CHANGELOG.txt
files: ./vsix-artifacts/**/*.vsix
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
generate_release_notes: true
publish:
name: Publish to Marketplace
needs: build
runs-on: ubuntu-latest
if: ${{ !contains(github.ref_name, '-') }}
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Check marketplace credentials
id: check-creds
run: |
if [ -n "${VSCE_KEY}" ]; then
echo "has_secret=true" >> "$GITHUB_OUTPUT"
else
echo "has_secret=false" >> "$GITHUB_OUTPUT"
echo "VSCE_KEY not set - skipping marketplace publish"
fi
env:
VSCE_KEY: ${{ secrets.VSCE_KEY }}
- name: Download VSIX artifact
if: steps.check-creds.outputs.has_secret == 'true'
uses: actions/download-artifact@v4
with:
path: ./vsix-artifacts
- name: Publish to VS Code Marketplace
if: steps.check-creds.outputs.has_secret == 'true'
env:
VSCE_PAT: ${{ secrets.VSCE_KEY }}
run: |
VSIX_FILE=$(find ./vsix-artifacts -name "*.vsix" -type f | head -1)
echo "Publishing: $VSIX_FILE"
npx @vscode/vsce publish --packagePath "$VSIX_FILE"