From 49cbd89efd4383e765b7b31d65055677fab2af34 Mon Sep 17 00:00:00 2001 From: Sam Lijin Date: Thu, 5 Dec 2024 19:06:18 -0800 Subject: [PATCH] again --- .github/workflows/release.yml | 370 ++++++++++++++++------------------ 1 file changed, 176 insertions(+), 194 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66ca53375..554cf416a 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 @@ -41,202 +47,178 @@ jobs: # - build-ruby-release # - build-typescript-release # - build-vscode-release - outputs: - should-run-publish-job: false - should-run-publish-step: true - should-run-publish-job2: ${{ startsWith(github.ref, 'refs/tags/') && 'true' }} - should-run-publish-step2: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/test-release') }} steps: - - if: github.ref_type == 'tag' - run: echo 'ref type is tag' - run: echo "::do-nothing::" >/dev/null - debug-output: + publish-to-pypi: + environment: release + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} + 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: + pattern: wheels-* + path: dist + merge-multiple: true + + # Verify we have the expected number of wheels + - name: Verify wheel count + run: | + set -euo pipefail + ls dist/ + wheel_count=$(ls dist/*.whl 2>/dev/null | wc -l) + if [ "$wheel_count" -lt 7 ]; then + echo "Error: Expected at least 7 wheels, but found $wheel_count" + exit 1 + fi + echo "Found $wheel_count 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: PyO3/maturin-action@v1 + with: + command: upload + args: dist/* + + publish-to-npm: + environment: release + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - name: setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.0.6 + package_json_file: engine/language_client_typescript/package.json + run_install: false + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + cache-dependency-path: engine/language_client_typescript/pnpm-lock.yaml + + - name: Install dependencies + run: pnpm install + working-directory: engine/language_client_typescript + + - uses: actions/download-artifact@v4 + with: + pattern: bindings-* + path: engine/language_client_typescript/artifacts + + - name: create npm dirs + run: pnpm napi create-npm-dirs + working-directory: engine/language_client_typescript + + - name: Move artifacts + run: pnpm artifacts + working-directory: engine/language_client_typescript + + - name: Publish + run: | + npm publish --access public + working-directory: engine/language_client_typescript + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-to-rubygems: + environment: release + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: rubygems/configure-rubygems-credentials@main + with: + # https://rubygems.org/profile/oidc/api_key_roles/rg_oidc_akr_p6x4xz53qtk948na3bgy + role-to-assume: rg_oidc_akr_p6x4xz53qtk948na3bgy + + - uses: jdx/mise-action@v2 + + - uses: actions/download-artifact@v4 + with: + pattern: gem-* + path: engine/language_client_ruby/pkg/ + merge-multiple: true + + - working-directory: engine/language_client_ruby + run: | + set -euxo pipefail + find pkg + for i in $(ls pkg/*.gem); do + gem push $i + done + + publish-to-github: + needs: [all-builds] + if: ${{ startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get Changelog + id: latest_release + run: | + echo "::set-output name=changelog::$(awk '/^## \[/{if (p) exit; p=1} p' CHANGELOG.md)" + + - name: Create Release + uses: mikepenz/action-gh-release@v1 #softprops/action-gh-release + with: + body: ${{steps.latest_release.outputs.changelog}} + + 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: - - if: needs.all-builds.outputs.should-run-publish-job - run: echo "should-run-publish-job true" - - if: needs.all-builds.outputs.should-run-publish-step == 'true' - run: echo "should-run-publish-step true" - - if: needs.all-builds.outputs.should-run-publish-job2 - run: echo "should-run-publish-job2 true" - - if: needs.all-builds.outputs.should-run-publish-step2 - run: echo "should-run-publish-step2 true" - - # publish-to-pypi: - # environment: release - # needs: [all-builds] - # if: needs.all-builds.outputs.should-run-publish-job - # 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: - # pattern: wheels-* - # path: dist - # merge-multiple: true - - # # Verify we have the expected number of wheels - # - name: Verify wheel count - # run: | - # set -euo pipefail - # ls dist/ - # wheel_count=$(ls dist/*.whl 2>/dev/null | wc -l) - # if [ "$wheel_count" -lt 7 ]; then - # echo "Error: Expected at least 7 wheels, but found $wheel_count" - # exit 1 - # fi - # echo "Found $wheel_count 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 - # if: needs.all-builds.outputs.should-run-publish-step - # uses: PyO3/maturin-action@v1 - # with: - # command: upload - # args: dist/* - - # publish-to-npm: - # environment: release - # needs: [all-builds] - # if: needs.all-builds.outputs.should-run-publish-job - # runs-on: ubuntu-latest - # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # steps: - # - uses: actions/checkout@v4 - - # - name: setup pnpm - # uses: pnpm/action-setup@v4 - # with: - # version: 9.0.6 - # package_json_file: engine/language_client_typescript/package.json - # run_install: false - - # - name: Setup node - # uses: actions/setup-node@v4 - # with: - # node-version: 20 - # cache: pnpm - # cache-dependency-path: engine/language_client_typescript/pnpm-lock.yaml - - # - name: Install dependencies - # run: pnpm install - # working-directory: engine/language_client_typescript - - # - uses: actions/download-artifact@v4 - # with: - # pattern: bindings-* - # path: engine/language_client_typescript/artifacts - - # - name: create npm dirs - # run: pnpm napi create-npm-dirs - # working-directory: engine/language_client_typescript - - # - name: Move artifacts - # run: pnpm artifacts - # working-directory: engine/language_client_typescript - - # - name: Publish - # if: needs.all-builds.outputs.should-run-publish-step - # run: | - # npm publish --access public - # working-directory: engine/language_client_typescript - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - # publish-to-rubygems: - # environment: release - # needs: [all-builds] - # if: needs.all-builds.outputs.should-run-publish-job - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # - uses: rubygems/configure-rubygems-credentials@main - # with: - # # https://rubygems.org/profile/oidc/api_key_roles/rg_oidc_akr_p6x4xz53qtk948na3bgy - # role-to-assume: rg_oidc_akr_p6x4xz53qtk948na3bgy - - # - uses: jdx/mise-action@v2 - - # - uses: actions/download-artifact@v4 - # with: - # pattern: gem-* - # path: engine/language_client_ruby/pkg/ - # merge-multiple: true - - # - working-directory: engine/language_client_ruby - # if: needs.all-builds.outputs.should-run-publish-step - # run: | - # set -euxo pipefail - # find pkg - # for i in $(ls pkg/*.gem); do - # gem push $i - # done - - # publish-to-github: - # needs: [all-builds] - # if: needs.all-builds.outputs.should-run-publish-job - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # - name: Get Changelog - # id: latest_release - # run: | - # echo "::set-output name=changelog::$(awk '/^## \[/{if (p) exit; p=1} p' CHANGELOG.md)" - - # - name: Create Release - # if: needs.all-builds.outputs.should-run-publish-step - # uses: mikepenz/action-gh-release@v1 #softprops/action-gh-release - # with: - # body: ${{steps.latest_release.outputs.changelog}} - - # publish-to-open-vsx: - # needs: [all-builds] - # runs-on: ubuntu-latest - # if: needs.all-builds.outputs.should-run-publish-job - # 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: needs.all-builds.outputs.should-run-publish-job - # 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 + - 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