Skip to content

Commit 98ed407

Browse files
committed
feature: update CI workflow and add support for code builds
1 parent baa5cdd commit 98ed407

File tree

1 file changed

+56
-17
lines changed

1 file changed

+56
-17
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,81 @@
11
name: CI
2+
23
on:
34
push:
4-
release:
5-
types:
6-
- created
5+
tags: ["v*"]
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
79

810
jobs:
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [macos-latest, windows-latest, ubuntu-latest]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Setup Node 12
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 12
22+
- name: Install dependencies
23+
run: npm ci
24+
- name: Run tests
25+
run: npm test
26+
927
package:
1028
runs-on: ubuntu-latest
29+
needs: build
1130
steps:
12-
- uses: actions/setup-node@v1
31+
- name: Package extension
32+
uses: lannonbr/vsce-action@master
1333
with:
14-
node-version: 12
15-
- uses: actions/checkout@v2
16-
- run: npm install
17-
- uses: docker://colinfang/vsce
34+
args: "package"
35+
- name: Get package name
36+
id: get_package_name
37+
run: |
38+
echo "::set-output name=name::$(echo textproto-grammer-*.vsix)"
39+
- name: Upload artifact
40+
uses: actions/upload-artifact@v2-preview
1841
with:
19-
args: package
20-
- uses: actions/upload-artifact@v2-preview
42+
name: extension-package
43+
path: ${{ steps.get_package_name.outputs.name }}
44+
45+
publish:
46+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
47+
runs-on: ubuntu-latest
48+
needs: build
49+
steps:
50+
- name: Publish extension
51+
uses: lannonbr/vsce-action@master
2152
with:
22-
name: vsix
23-
path: "*.vsix"
53+
args: "publish -p ${{ secrets.VSCE_TOKEN }}"
2454

2555
release:
26-
if: github.event_name == 'release'
56+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
2757
runs-on: ubuntu-latest
2858
needs: package
2959
steps:
60+
- name: Create release
61+
id: create_release
62+
uses: actions/create-release@v1
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
with:
66+
tag_name: ${{ github.ref }}
67+
release_name: ${{ github.ref }}
3068
- uses: actions/download-artifact@v2-preview
3169
with:
32-
name: vsix
70+
name: extension-package
3371
- id: find_file_name
3472
run: echo "::set-output name=file::$(ls *.vsix)"
35-
- uses: actions/upload-release-asset@v1
73+
- name: Upload release artifact
74+
uses: actions/upload-release-asset@v1
3675
env:
3776
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3877
with:
39-
upload_url: ${{ github.event.release.upload_url }}
78+
upload_url: ${{ steps.create_release.outputs.upload_url }}
4079
asset_path: ${{ steps.find_file_name.outputs.file }}
4180
asset_name: ${{ steps.find_file_name.outputs.file }}
42-
asset_content_type: application/zip
81+
asset_content_type: application/vsix

0 commit comments

Comments
 (0)