Skip to content

Merge pull request #226 from viperproject/auto-update-vscode #692

Merge pull request #226 from viperproject/auto-update-vscode

Merge pull request #226 from viperproject/auto-update-vscode #692

Workflow file for this run

name: Test and publish
on:
workflow_dispatch:
pull_request:
push:
branches: "master"
jobs:
# Test the extension on multiple OSs.
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '15'
distribution: 'zulu'
- name: Install NPM dependencies
run: npm install
- name: Run linter
run: npm run lint
- name: Package the extension
run: npm run package
- name: Run tests (headless)
uses: GabrielBB/[email protected]
id: runTests
with:
run: npm test --full-trace
env:
GITHUB_TOKEN: ${{ secrets.VIPER_ADMIN_TOKEN }}
- name: Collect coverage
if: ${{ steps.runTests.outcome == 'success' }}
run: npx nyc report --reporter=lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: ${{ steps.runTests.outcome == 'success' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/lcov.info
# Publish the extension when we are on master and the version specified in
# package.json is not the latest published version of the extension.
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Install NPM dependencies
run: npm install
- name: Obtain version information
run: |
LAST_PUBLISHED_VERSION="$(
npx vsce show viper-admin.prusti-assistant --json \
| jq '.versions[0].version' --raw-output
)"
CURRENT_VERSION="$(
cat package.json | jq '.version' --raw-output
)"
echo "LAST_PUBLISHED_VERSION=$LAST_PUBLISHED_VERSION" >> $GITHUB_ENV
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Package the extension
run: npm run package
- name: Publish the extension to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v0
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
with:
pat: ${{ secrets.VSCE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
packagePath: ''
- name: Publish the extension to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v0
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
registryUrl: https://open-vsx.org
extensionFile: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
packagePath: ''
- name: Create a release for the published version
id: create_release
uses: actions/create-release@v1
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.CURRENT_VERSION }}
release_name: Release v${{ env.CURRENT_VERSION }}
- name: Upload release asset
uses: actions/upload-release-asset@v1
if: env.CURRENT_VERSION != env.LAST_PUBLISHED_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
asset_name: prusti-assistant-${{ env.CURRENT_VERSION }}.vsix
asset_content_type: application/zip