Publish types to NPM #91
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish types to NPM | |
on: | |
# Since we still need to manually upload binaries, use manual run | |
# Ideally this would trigger off `release` | |
workflow_dispatch: | |
inputs: | |
patch: | |
description: 'Patch Version' | |
required: true | |
default: '0' | |
prerelease: | |
description: 'Is Prerelease' | |
type: boolean | |
default: false | |
jobs: | |
version: | |
outputs: | |
version: ${{ steps.echo.outputs.version }} | |
date: ${{ steps.echo.outputs.date }} | |
release_version: ${{ steps.echo.outputs.release_version }} | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- id: echo | |
run: | | |
echo "date=$(cat src/workerd/io/supported-compatibility-date.txt)" >> $GITHUB_OUTPUT; | |
echo "version=${{ inputs.prerelease == false && '4' || '0'}}.$(cat src/workerd/io/supported-compatibility-date.txt | tr -d '-').${{ inputs.patch }}" >> $GITHUB_OUTPUT; | |
echo "release_version=1.$(cat src/workerd/io/supported-compatibility-date.txt | tr -d '-').0" >> $GITHUB_OUTPUT; | |
build-and-publish-types: | |
runs-on: ubuntu-20.04 | |
needs: version | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- name: Cache | |
id: cache | |
uses: actions/cache@v4 | |
# Use same cache and build configuration as release build, this allows us to keep download | |
# sizes small and generate types with optimization enabled, should be slightly faster. | |
with: | |
path: ~/bazel-disk-cache | |
key: bazel-disk-cache-release-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }} | |
- name: Setup Linux | |
run: | | |
export DEBIAN_FRONTEND=noninteractive | |
wget https://apt.llvm.org/llvm.sh | |
sed -i '/apt-get install/d' llvm.sh | |
chmod +x llvm.sh | |
sudo ./llvm.sh 16 | |
sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev | |
echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc | |
echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc | |
- name: build types | |
run: | | |
bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux //types:types | |
- name: Build package | |
run: node npm/scripts/build-types-package.mjs | |
env: | |
WORKERD_VERSION: ${{ needs.version.outputs.version }} | |
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }} | |
- run: cp -r bazel-bin/types/definitions/. npm/workers-types | |
- run: cp npm/workers-types/oldest/* npm/workers-types | |
- run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > npm/workers-types/.npmrc | |
- run: cd npm/workers-types && npm publish --access public --tag ${{ inputs.prerelease == true && 'alpha' || 'latest'}} | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} |