|
1 | 1 | name: CI
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | push:
|
4 |
| - release: |
5 |
| - types: |
6 |
| - - created |
| 5 | + tags: ["v*"] |
| 6 | + branches: [main] |
| 7 | + pull_request: |
| 8 | + branches: [main] |
7 | 9 |
|
8 | 10 | 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 | + |
9 | 27 | package:
|
10 | 28 | runs-on: ubuntu-latest
|
| 29 | + needs: build |
11 | 30 | steps:
|
12 |
| - - uses: actions/setup-node@v1 |
| 31 | + - name: Package extension |
| 32 | + uses: lannonbr/vsce-action@master |
13 | 33 | 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 |
18 | 41 | 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 |
21 | 52 | with:
|
22 |
| - name: vsix |
23 |
| - path: "*.vsix" |
| 53 | + args: "publish -p ${{ secrets.VSCE_TOKEN }}" |
24 | 54 |
|
25 | 55 | release:
|
26 |
| - if: github.event_name == 'release' |
| 56 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
27 | 57 | runs-on: ubuntu-latest
|
28 | 58 | needs: package
|
29 | 59 | 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 }} |
30 | 68 | - uses: actions/download-artifact@v2-preview
|
31 | 69 | with:
|
32 |
| - name: vsix |
| 70 | + name: extension-package |
33 | 71 | - id: find_file_name
|
34 | 72 | 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 |
36 | 75 | env:
|
37 | 76 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
38 | 77 | with:
|
39 |
| - upload_url: ${{ github.event.release.upload_url }} |
| 78 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
40 | 79 | asset_path: ${{ steps.find_file_name.outputs.file }}
|
41 | 80 | asset_name: ${{ steps.find_file_name.outputs.file }}
|
42 |
| - asset_content_type: application/zip |
| 81 | + asset_content_type: application/vsix |
0 commit comments