Skip to content

u

u #5

Workflow file for this run

name: Publish Types to npm
on:
push:
branches:
- npm
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g. 0.14.0)'
required: true
jobs:
publish-types:
runs-on: ubuntu-22.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Cache OpenAPI spec
if: github.event_name == 'push'
id: cache-openapi
uses: actions/cache@v4
with:
path: landscape-types/openapi.json
key: openapi-spec-${{ hashFiles('landscape-webserver/src/**', 'Cargo.lock') }}
- name: Install system dependencies
if: steps.cache-openapi.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y cmake clang curl gcc llvm make pkg-config libelf-dev libclang-dev zlib1g-dev
- name: Setup Rust
if: steps.cache-openapi.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@stable
- name: Generate OpenAPI spec
if: steps.cache-openapi.outputs.cache-hit != 'true'
run: cargo test -p landscape-webserver export_openapi_json -- --nocapture
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Install dependencies & generate types
run: |
pnpm install --frozen-lockfile
pnpm --filter @landscape-router/types generate
- name: Set version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "landscape-webserver") | .version')
fi
cd landscape-types
pnpm pkg set version="$VERSION"
- name: Verify npm token
run: |
if [ -z "$NPM_TOKEN" ]; then
echo "::error::NPM_TOKEN secret is empty!"
exit 1
fi
echo "Token starts with: ${NPM_TOKEN:0:8}..."
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
cat ~/.npmrc | head -c 50
echo "..."
npm whoami --registry https://registry.npmjs.org || echo "whoami failed"
pnpm --filter @landscape-router/types publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}