From cd5dc4c1690ea9d713ccabef1baf167f26e60807 Mon Sep 17 00:00:00 2001 From: Samuel Lijin Date: Thu, 5 Dec 2024 19:37:04 -0800 Subject: [PATCH] feat: automate vscode extension releases (both vscode and cursor) (#1222) - add vscode extension release to the pipeline - add cursor extension release (open-vsx) to the pipeline - allow ad-hoc extension releases via "force publish vscode" for putting out the vscode extension (this is half-baked right now, requirement is according to aaron) --- .../build-python-release.reusable.yaml | 2 +- .../build-ruby-release.reusable.yaml | 2 +- .../build-typescript-release.reusable.yaml | 2 +- .../build-vscode-release.reusable.yaml | 77 +++++++ .github/workflows/release.yml | 216 ++++++------------ .../language_client_typescript/package.json | 3 +- typescript/pnpm-lock.yaml | 30 +-- 7 files changed, 160 insertions(+), 172 deletions(-) create mode 100644 .github/workflows/build-vscode-release.reusable.yaml diff --git a/.github/workflows/build-python-release.reusable.yaml b/.github/workflows/build-python-release.reusable.yaml index 89caa920c..1d6841b14 100644 --- a/.github/workflows/build-python-release.reusable.yaml +++ b/.github/workflows/build-python-release.reusable.yaml @@ -1,4 +1,4 @@ -name: Release language_client_python +name: BAML Release - Build Python on: workflow_call: {} diff --git a/.github/workflows/build-ruby-release.reusable.yaml b/.github/workflows/build-ruby-release.reusable.yaml index 055512b65..966172f26 100644 --- a/.github/workflows/build-ruby-release.reusable.yaml +++ b/.github/workflows/build-ruby-release.reusable.yaml @@ -1,4 +1,4 @@ -name: Release engine/language_client_ruby +name: BAML Release - Build Ruby on: workflow_call: {} diff --git a/.github/workflows/build-typescript-release.reusable.yaml b/.github/workflows/build-typescript-release.reusable.yaml index 8df43c8da..90eaa584a 100644 --- a/.github/workflows/build-typescript-release.reusable.yaml +++ b/.github/workflows/build-typescript-release.reusable.yaml @@ -1,4 +1,4 @@ -name: Release language_client_typescript +name: BAML Release - Build Typescript on: workflow_call: {} diff --git a/.github/workflows/build-vscode-release.reusable.yaml b/.github/workflows/build-vscode-release.reusable.yaml new file mode 100644 index 000000000..9cdfefe6a --- /dev/null +++ b/.github/workflows/build-vscode-release.reusable.yaml @@ -0,0 +1,77 @@ +name: BAML Release - Build VSCode Extension + +on: + workflow_call: {} + +concurrency: + # suffix is important to prevent a concurrency deadlock with the calling workflow + group: ${{ github.workflow }}-${{ github.ref }}-build-vscode + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: jdx/mise-action@v2 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + with: + workspaces: engine + - name: Bindgen + run: cargo install -f wasm-bindgen-cli@0.2.92 + working-directory: engine/baml-schema-wasm + # Set up Node.js + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + cache: "pnpm" + node-version: 20 + cache-dependency-path: | + typescript/**/pnpm-lock.yaml + - name: Install Dependencies + run: pnpm install --frozen-lockfile + working-directory: typescript/ + - name: Build Typescript Project + run: pnpm run build + working-directory: typescript/ + + # Build the VSCode Extension + - name: Build VSCode Extension + id: build + run: pnpm run vscode:package + working-directory: typescript/vscode-ext/packages + + # Upload the artifact (helpful for debugging and manual downloads) + - name: Upload VSCode Extension Artifact + uses: actions/upload-artifact@v4 + with: + name: baml-vscode-vsix + path: typescript/vscode-ext/packages/*.vsix + if-no-files-found: error + + # Upload the artifact (helpful for debugging and manual downloads) + - name: Upload VSCode Extension Artifact + uses: actions/upload-artifact@v4 + with: + name: baml-out + path: typescript/vscode-ext/packages/vscode/out + if-no-files-found: error + + # upload the lang server artifact + - name: Upload VSCode Lang Server Extension Artifact + uses: actions/upload-artifact@v4 + with: + name: language-server + path: typescript/vscode-ext/packages/language-server/out + if-no-files-found: error + + - name: VSCode Playground Artifact + uses: actions/upload-artifact@v4 + with: + name: vscode-playground + path: typescript/vscode-ext/packages/web-panel/dist + if-no-files-found: error diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de3fdafd9..a8e2572e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,13 @@ name: BAML Release on: - workflow_dispatch: {} + workflow_dispatch: + inputs: + force_publish_vscode: + description: "Force publish to VSCode Marketplace and Open VSX" + type: boolean + required: false + default: false # need to run this periodically on the default branch to populate the build cache schedule: # daily at 2am PST @@ -10,6 +16,7 @@ on: tags: - "test-release/*.*" - "*.*" + branches: [] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -19,77 +26,6 @@ permissions: id-token: write jobs: - build-wasm: - runs-on: ubuntu-latest - name: Build WASM - steps: - - uses: actions/checkout@v4 - - uses: jdx/mise-action@v2 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: wasm32-unknown-unknown - - uses: Swatinem/rust-cache@v2 - with: - workspaces: engine - - name: Bindgen - run: cargo install -f wasm-bindgen-cli@0.2.92 - working-directory: engine/baml-schema-wasm - # Set up Node.js - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: "pnpm" - node-version: 20 - cache-dependency-path: | - typescript/**/pnpm-lock.yaml - - name: Install Dependencies - run: pnpm install --frozen-lockfile - working-directory: typescript/ - - name: Build Typescript Project - run: pnpm run build - working-directory: typescript/ - - # Build the VSCode Extension - - name: Build VSCode Extension - id: build - run: | - pnpm run vscode:package - VERSION=$(cat package.json| grep version | cut -d ' ' -f 4 | sed 's/[",]//g') - echo "version=$VERSION" >> $GITHUB_OUTPUT - working-directory: typescript/vscode-ext/packages - - # Upload the artifact (helpful for debugging and manual downloads) - - name: Upload VSCode Extension Artifact - uses: actions/upload-artifact@v4 - with: - name: baml-vscode.vsix - path: typescript/vscode-ext/packages/baml-extension-${{ steps.build.outputs.version }}.vsix - if-no-files-found: error - - # Upload the artifact (helpful for debugging and manual downloads) - - name: Upload VSCode Extension Artifact - uses: actions/upload-artifact@v4 - with: - name: baml-out - path: typescript/vscode-ext/packages/vscode/out - if-no-files-found: error - - # upload the lang server artifact - - name: Upload VSCode Lang Server Extension Artifact - uses: actions/upload-artifact@v4 - with: - name: language-server - path: typescript/vscode-ext/packages/language-server/out - if-no-files-found: error - - - name: VSCode Playground Artifact - uses: actions/upload-artifact@v4 - with: - name: vscode-playground - path: typescript/vscode-ext/packages/web-panel/dist - if-no-files-found: error - build-python-release: uses: ./.github/workflows/build-python-release.reusable.yaml @@ -99,21 +35,25 @@ jobs: build-typescript-release: uses: ./.github/workflows/build-typescript-release.reusable.yaml + build-vscode-release: + uses: ./.github/workflows/build-vscode-release.reusable.yaml + # placeholder fan-in step - assert-all-builds-passed: + all-builds: + name: Assert all builds passed runs-on: ubuntu-latest needs: - build-python-release - - build-typescript-release - build-ruby-release - - build-wasm + - build-typescript-release + - build-vscode-release steps: - - run: true - + - run: echo "::do-nothing::" >/dev/null + publish-to-pypi: environment: release - if: github.ref_type == 'tag' - needs: [assert-all-builds-passed] + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -141,7 +81,6 @@ jobs: # authz is managed via OIDC configured at https://pypi.org/manage/project/baml-py/settings/publishing/ # it is pinned to this github actions filename, so renaming this file is not safe!! - name: Publish package to PyPI - if: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/test-release') }} uses: PyO3/maturin-action@v1 with: command: upload @@ -149,8 +88,8 @@ jobs: publish-to-npm: environment: release - if: github.ref_type == 'tag' - needs: [assert-all-builds-passed] + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -170,7 +109,6 @@ jobs: node-version: 20 cache: pnpm cache-dependency-path: engine/language_client_typescript/pnpm-lock.yaml - registry-url: "https://registry.npmjs.org" - name: Install dependencies run: pnpm install @@ -190,7 +128,6 @@ jobs: working-directory: engine/language_client_typescript - name: Publish - if: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/test-release') }} run: | npm publish --access public working-directory: engine/language_client_typescript @@ -200,8 +137,8 @@ jobs: publish-to-rubygems: environment: release - if: github.ref_type == 'tag' - needs: [assert-all-builds-passed] + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -227,63 +164,10 @@ jobs: gem push $i done - # publish-vscode: - # environment: release - # needs: [build-release, build-wasm] - # if: github.ref_type == 'tag' - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # # Get all the artifacts - # - name: Get artifact - # uses: actions/download-artifact@v4 - # with: - # name: baml-vscode.vsix - # path: typescript/vscode-ext/packages - # - name: Get artifact - # uses: actions/download-artifact@v4 - # with: - # name: baml-out - # path: typescript/vscode-ext/packages/vscode/out - # - name: Get artifact - # uses: actions/download-artifact@v4 - # with: - # name: language-server - # path: typescript/vscode-ext/packages/language-server/out - # - name: Get artifact - # uses: actions/download-artifact@v4 - # with: - # pattern: vscode-playground - # path: typescript/vscode-ext/packages/web-panel/dist - - # - name: setup pnpm - # uses: pnpm/action-setup@v4 - # with: - # version: 9.0.6 - # package_json_file: typescript/package.json - # run_install: false - # # Set up Node.js - # - name: Setup Node.js - # uses: actions/setup-node@v4 - # with: - # cache: "pnpm" - # node-version: 20 - # cache-dependency-path: typescript/pnpm-lock.yaml - - # - name: Install Dependencies - # run: pnpm install --frozen-lockfile - # working-directory: typescript/ - # - name: Publish - # if: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/test-release') }} - # run: | - # pnpm run vscode:publish --no-git-tag-version -p ${{ secrets.VSCODE_PAT }} - # working-directory: typescript/vscode-ext/packages - - release-github: + publish-to-github: + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest - if: github.ref_type == 'tag' - needs: [assert-all-builds-passed] steps: - uses: actions/checkout@v4 @@ -292,13 +176,49 @@ jobs: run: | echo "::set-output name=changelog::$(awk '/^## \[/{if (p) exit; p=1} p' CHANGELOG.md)" - - uses: actions/download-artifact@v4 - with: - path: gh-artifacts - merge-multiple: true - - name: Create Release uses: mikepenz/action-gh-release@v1 #softprops/action-gh-release with: body: ${{steps.latest_release.outputs.changelog}} - files: gh-artifacts/* + + publish-to-open-vsx: + needs: [all-builds] + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.force_publish_vscode }} + steps: + - uses: actions/checkout@v4 + - uses: jdx/mise-action@v2 + - name: Install Dependencies + run: pnpm install --frozen-lockfile + working-directory: typescript/ + - uses: actions/download-artifact@v4 + with: + name: baml-vscode-vsix + path: typescript/vscode-ext/packages/out/ + - name: Publish to open-vsx + run: | + cd typescript/vscode-ext/packages + pnpm ovsx publish --packagePath ./out/*.vsix + env: + OVSX_PAT: ${{ secrets.OVSX_PAT }} + + publish-to-vscode-marketplace: + needs: [all-builds] + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.force_publish_vscode }} + steps: + - uses: actions/checkout@v4 + - uses: jdx/mise-action@v2 + - name: Install Dependencies + run: pnpm install --frozen-lockfile + working-directory: typescript/ + - uses: actions/download-artifact@v4 + with: + name: baml-vscode-vsix + path: typescript/vscode-ext/packages/out/ + - name: Publish to VSCode Marketplace + run: | + cd typescript/vscode-ext/packages + pnpm vsce publish --packagePath ./out/*.vsix + env: + VSCE_PAT: ${{ secrets.VSCODE_PAT }} \ No newline at end of file diff --git a/engine/language_client_typescript/package.json b/engine/language_client_typescript/package.json index 7306365c8..9b582ec1e 100644 --- a/engine/language_client_typescript/package.json +++ b/engine/language_client_typescript/package.json @@ -4,7 +4,8 @@ "description": "BAML typescript bindings (package.json)", "repository": { "type": "git", - "url": "git+https://github.com/BoundaryML/baml.git" + "url": "https://github.com/BoundaryML/baml.git", + "directory": "engine/language_client_typescript" }, "license": "MIT", "keywords": [ diff --git a/typescript/pnpm-lock.yaml b/typescript/pnpm-lock.yaml index 2fec60a07..173b104ca 100644 --- a/typescript/pnpm-lock.yaml +++ b/typescript/pnpm-lock.yaml @@ -12924,8 +12924,8 @@ snapshots: '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.2.2) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0)(eslint@8.57.1) - eslint-plugin-import: 2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1))(eslint@8.57.1) + eslint-plugin-import: 2.30.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.0(eslint@8.57.1) eslint-plugin-react: 7.37.1(eslint@8.57.1) eslint-plugin-react-hooks: 4.6.2(eslint@8.57.1) @@ -12948,47 +12948,37 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0)(eslint@8.57.1): + eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1))(eslint@8.57.1): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.3.7 enhanced-resolve: 5.17.1 eslint: 8.57.1 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) fast-glob: 3.3.2 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 is-glob: 4.0.3 optionalDependencies: - eslint-plugin-import: 2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1) + eslint-plugin-import: 2.30.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) transitivePeerDependencies: - '@typescript-eslint/parser' - eslint-import-resolver-node - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): + eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): dependencies: debug: 3.2.7 optionalDependencies: '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.2.2) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0)(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1))(eslint@8.57.1) transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1): - dependencies: - debug: 3.2.7 - optionalDependencies: - '@typescript-eslint/parser': 8.8.0(eslint@8.57.1)(typescript@5.2.2) - eslint: 8.57.1 - eslint-import-resolver-node: 0.3.9 - transitivePeerDependencies: - - supports-color - - eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1): + eslint-plugin-import@2.30.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.8 @@ -12999,7 +12989,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.30.0(@typescript-eslint/parser@8.8.0(eslint@8.57.1)(typescript@5.2.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 @@ -13010,7 +13000,7 @@ snapshots: semver: 6.3.1 tsconfig-paths: 3.15.0 optionalDependencies: - '@typescript-eslint/parser': 8.8.0(eslint@8.57.1)(typescript@5.2.2) + '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.2.2) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack