-
Notifications
You must be signed in to change notification settings - Fork 6
161 lines (158 loc) · 5.6 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
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
name: CI
on:
push:
branches:
- master
paths-ignore:
- ".vscode/**"
- ".github/**"
- "*.md"
- "**/*.md"
pull_request:
branches:
- master
release:
types:
- released
concurrency:
group: ${{ github.workflow }}-${{ github.base_ref || github.run_id }}
cancel-in-progress: false
jobs:
build:
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
matrix:
platarch: [win32-x64, linux-x64, linux-arm64, alpine-x64, alpine-arm64, darwin-x64, darwin-arm64]
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set package name and version
id: set-version
run: |
set -x
VERSION=$(jq -r '.version' package.json | cut -d- -f1)
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
git tag -l | cat
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
NAME=$(jq -r '.name' package.json)-$VERSION-${{ matrix.platarch }}
echo "name=$NAME" >> $GITHUB_OUTPUT
tmp=$(mktemp)
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
echo $VERSION > meta.version
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- name: Use correct .node binary file
run: cp -f ./server/lib/${{ matrix.platarch }}-isclexer.node ./server/lib/isclexer.node
- name: Build package
run: npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix --target ${{ matrix.platarch }}
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-version.outputs.name }}.vsix
path: ${{ steps.set-version.outputs.name }}.vsix
retention-days: 30
- name: Upload metadata
if: matrix.platarch == 'linux-arm64'
uses: actions/upload-artifact@v4
with:
name: meta
retention-days: 1
path: meta.version
beta:
runs-on: ubuntu-latest
needs: build
if: success() && github.event_name == 'push'
steps:
- name: Download metadata
uses: actions/download-artifact@v4
with:
name: meta
path: .
- name: Set version output
id: set-version
run: |
set -x
echo "version=`cat meta.version`" >> $GITHUB_OUTPUT
- name: Download packages
uses: actions/download-artifact@v4
with:
pattern: '**/*.vsix'
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: '**/*.vsix'
token: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
needs: build
if: success() && github.event_name == 'release'
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g @vscode/vsce
- name: Download packages
uses: actions/download-artifact@v4
- name: Attach packages to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name }}
files: '**/*.vsix'
body: See CHANGELOG for details
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
if: env.VSCE_PAT != null
run: vsce publish --packagePath $(find . -iname "*.vsix" -type f)
- name: Publish to Open VSX Registry
env:
OVSX_PAT: ${{ secrets.OVSX_TOKEN }}
if: env.OVSX_PAT != null
timeout-minutes: 5
run: find . -iname "*.vsix" -type f -exec npx ovsx publish {} \;
bump_version:
runs-on: ubuntu-latest
needs: [build, publish]
if: github.event_name == 'release'
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: master
- name: Download metadata
uses: actions/download-artifact@v4
with:
name: meta
path: .
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Create commit
run: |
VERSION=`cat meta.version`
NEXT_VERSION=`cat meta.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
tmp=$(mktemp)
git config --global user.name 'ProjectBot'
git config --global user.email '[email protected]'
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' ./client/package.json > "$tmp" && mv "$tmp" ./client/package.json
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' ./server/package.json > "$tmp" && mv "$tmp" ./server/package.json
git add package.json
git add ./client/package.json
git add ./server/package.json
git commit -m 'auto bump version with release [skip ci]'
git push