Add extension packaging to build and test action #12
Workflow file for this run
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: Build and Test VS Code Extension | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# VS Code uses Node 18 | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- run: yarn install | |
- run: yarn test:ci | |
- name: Package the extension | |
id: package | |
# Uploaded extension name will include the version and current git sha. | |
run: | | |
yarn package | |
PACKAGE_PATH=$(find . -name 'vscode-bazel-bsp-*.vsix') | |
PACKAGE_NAME_WITH_SHA="${PACKAGE_PATH%.vsix}-$(echo $GITHUB_SHA | cut -c1-7).vsix" | |
echo "package_path=$PACKAGE_PATH" >> $GITHUB_ENV | |
echo "package_name_with_sha=$(basename $PACKAGE_NAME_WITH_SHA)" >> $GITHUB_ENV | |
upload-artifact: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload packaged extension artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.package_name_with_sha }} | |
path: ${{ env.package_path }} |