Skip to content

fix gradle

fix gradle #419

name: 'build and release'
env:
NODE_VERSION: '18' # Shipped with VS Code.
ARTIFACT_NAME_VSIX: vsix
VSIX_NAME: vscode-pyright.vsix
VSIX_DIR: packages/vscode-pyright
NPM_PACKAGE_DIR: packages/pyright
on: push
jobs:
build-and-release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
pull-requests: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get npm cache directory
id: npm-cache
shell: bash
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: ./pw pdm install
- id: current-version
run: echo ::set-output name=CURRENT_VERSION::$(./pw pdm show --version)
- name: get currently published npm package version
if: github.ref == 'refs/heads/main'
run: echo ::set-output name=VERSION_INFO::$(npm view $(node -p "require(\"./package.json\").name")@=${{ steps.current-version.outputs.CURRENT_VERSION }})
id: version-was-changed
working-directory: ${{ env.NPM_PACKAGE_DIR }}
- name: set version for publishing
if: github.ref == 'refs/heads/main'
run: ./node_modules/.bin/lerna version ${{ steps.current-version.outputs.CURRENT_VERSION }} --yes --no-git-tag-version
- name: Build VSIX
working-directory: ${{ env.VSIX_DIR }}
run: |
npm run package
mv basedpyright-*.vsix ${{ env.VSIX_NAME }}
- uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME_VSIX }}
path: ${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }}
# publish npm canary version on every push to every branch except main
- name: set version for npm canary
if: github.ref != 'refs/heads/main'
run: npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --git-tag-version false
working-directory: ${{ env.NPM_PACKAGE_DIR }}
- name: publish package - npm canary
if: github.ref != 'refs/heads/main'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
tag: canary
package: ${{ env.NPM_PACKAGE_DIR }}/package.json
- name: publish package - npm
# publish npm & pypi packages, vscode extension and github release if the version in lerna.json was changed:
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: ${{ env.NPM_PACKAGE_DIR }}/package.json
- name: publish package - pypi
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: ./pw pdm publish
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token
- name: publish VSIX - visual studio marketplace
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: ./node_modules/.bin/vsce publish --packagePath ${{ env.VSIX_NAME }} --pat ${{ secrets.VSCE_TOKEN }} --noVerify
working-directory: ${{ env.VSIX_DIR }}
- name: publish VSIX - open VSX
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: ./node_modules/.bin/ovsx publish --packagePath ${{ env.VSIX_NAME }} --pat ${{ secrets.OPEN_VSX_TOKEN }}
working-directory: ${{ env.VSIX_DIR }}
- uses: marvinpinto/[email protected]
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: |
dist/*
${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }}
automatic_release_tag: v${{ steps.current-version.outputs.CURRENT_VERSION }}