diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index debbeedf9..6de3d6d61 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,10 +2,8 @@ name: BAML Runtime on: push: - paths: - - "engine/**" tags: - - v* + - "*.*" concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -13,10 +11,79 @@ concurrency: permissions: contents: read - pull-requests: read - repository-projects: read + id-token: write jobs: + build-wasm: + runs-on: ubuntu-latest + name: Build WASM + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + with: + workspaces: engine + - name: Bindgen + run: cargo update -p wasm-bindgen + working-directory: engine/baml-schema-wasm + - uses: pnpm/action-setup@v3 + with: + version: 8 + package_json_file: typescript/package.json + run_install: false + # Set up Node.js + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + cache: "pnpm" + node-version: 18 + 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-${{ steps.build.outputs.version }}.vsix + + # 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 + + # 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 + + - name: VSCode Playground Artifact + uses: actions/upload-artifact@v4 + with: + name: vscode-playground + path: typescript/vscode-ext/packages/web-panel/dist + build-release: strategy: fail-fast: true @@ -46,7 +113,7 @@ jobs: host: ubuntu-latest node_build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross - name: Build ${{ matrix._.name }} + name: Build ${{ matrix._.target }} runs-on: ${{ matrix._.host }} steps: - uses: actions/checkout@v4 @@ -125,3 +192,79 @@ jobs: name: bindings-${{ matrix._.target }} path: engine/language_client_typescript/*.node if-no-files-found: error + + publish-to-pypi: + environment: release + needs: [build-release, build-wasm] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.8" + - uses: actions/download-artifact@v4 + with: + name: wheels-* + + # 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 + uses: pypa/gh-action-pypi-publish@release/v1 + + publish-to-npm: + environment: release + needs: [build-release, build-wasm] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - uses: actions/download-artifact@v4 + with: + name: bindings-* + + publish-vscode: + environment: release + needs: [build-release, build-wasm] + 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: + name: vscode-playground + path: typescript/vscode-ext/packages/web-panel/dist + + # Set up Node.js + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + cache: "pnpm" + node-version: 18 + cache-dependency-path: typescript/pnpm-lock.yaml + + - name: Install Dependencies + run: pnpm install --frozen-lockfile + working-directory: typescript/ + - name: Publish + run: | + pnpm run vscode:publish --pre-release --no-git-tag-version -p ${{ secrets.VSCODE_PAT }} + working-directory: typescript/vscode-ext/packages \ No newline at end of file