chore: Update ci.yml #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
tags: ["v*"] | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
NODE_VERSION: 20 | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest, windows-latest, ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm test | |
package: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: npm ci | |
- name: Package extension | |
uses: lannonbr/vsce-action@master | |
with: | |
args: "package" | |
- name: Get package name | |
id: get_package_name | |
run: | | |
echo "::set-output name=name::$(echo textproto-grammer-*.vsix)" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: extension-package | |
path: ${{ steps.get_package_name.outputs.name }} | |
publish: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: npm ci | |
- name: Publish extension | |
uses: lannonbr/vsce-action@master | |
with: | |
args: "publish -p ${{ secrets.VSCE_TOKEN }}" | |
release: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: package | |
steps: | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
- uses: actions/download-artifact@v2-preview | |
with: | |
name: extension-package | |
- id: find_file_name | |
run: echo "::set-output name=file::$(ls *.vsix)" | |
- name: Upload release artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.find_file_name.outputs.file }} | |
asset_name: ${{ steps.find_file_name.outputs.file }} | |
asset_content_type: application/vsix |