-
Notifications
You must be signed in to change notification settings - Fork 58
114 lines (102 loc) · 3.65 KB
/
package-extension.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
109
110
111
112
113
114
name: Package vscode-extension
on:
workflow_dispatch:
inputs:
publish:
description: 'Publish to marketplaces'
default: false
type: boolean
target_macos:
description: 'macOS'
default: true
type: boolean
target_windows:
description: 'Windows'
default: false
type: boolean
target_linux:
description: 'Linux'
default: false
type: boolean
ref:
description: 'The branch, tag or SHA to checkout'
default: 'main'
type: string
jobs:
build-and-publish:
runs-on: macos-latest
steps:
- name: Set workflow start time
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H%M%S')"
- name: Set targets
id: set_targets
run: |
targets=""
if ${{ github.event.inputs.target_macos }}; then
targets="$targets darwin-arm64"
fi
if ${{ github.event.inputs.target_windows }}; then
targets="$targets win32-x64"
fi
if ${{ github.event.inputs.target_linux }}; then
targets="$targets linux-x64"
fi
if [ -z "$targets" ]; then
echo "No targets specified"
exit 1
fi
echo "Building extension for targets: $targets"
echo "::set-output name=targets::$targets"
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Enforce HTTPS for submodules
run: git config --global url."https://github.com/".insteadOf "[email protected]:"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: packages/vscode-extension/package-lock.json
- name: Install dependencies
working-directory: packages/vscode-extension
run: npm ci
- name: Prepare package name for artifact upload
id: prepare_name
run: |
ref_name=$(echo -n "${{ github.event.inputs.ref }}" | xargs | sed 's/[\\\/'"'"':<>|*?]/-/g')
package_name=radon-ide-${ref_name}-${{ steps.date.outputs.date }}
echo "package_name=$package_name" >> $GITHUB_OUTPUT
- name: Package extension
working-directory: packages/vscode-extension
id: package_extension
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
out_path=/tmp/${{ steps.prepare_name.outputs.package_name }}.vsix
vsce package --out $out_path --target ${{ steps.set_targets.outputs.targets }}
echo "vsix_path=$out_path" >> $GITHUB_OUTPUT
- name: Upload extension artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_name.outputs.package_name }}
path: ${{ steps.package_extension.outputs.vsix_path }}
- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
if: ${{ github.event.inputs.publish == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ steps.package_extension.outputs.vsix_path }}
pat: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
- name: Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v1
if: ${{ github.event.inputs.publish == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
extensionFile: ${{ steps.package_extension.outputs.vsix_path }}
pat: ${{ secrets.OPENVSX_MARKETPLACE_TOKEN }}