pulumi/.github/workflows/ci-build-sdks.yml

124 lines
3.5 KiB
YAML

name: Build SDKs
permissions:
contents: read
on:
workflow_call:
inputs:
ref:
required: true
description: "GitHub ref to use"
type: string
version:
required: true
description: "Version to produce"
type: string
version-set:
required: false
description: "Set of language versions to use for builds, lints, releases, etc."
type: string
# Example provided for illustration, this value is derived by scripts/get-job-matrix.py build
default: |
{
"dotnet": "6.0.x",
"go": "1.18.x",
"nodejs": "16.x",
"python": "3.9.x"
}
defaults:
run:
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULUMI_VERSION: ${{ inputs.version }}
jobs:
build_python_sdk:
name: python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Setup versioning env vars
env:
version: ${{ inputs.version }}
run: |
./scripts/versions.sh | tee -a "${GITHUB_ENV}"
- name: Set up uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: sdk/python/uv.lock
- name: Set up Python ${{ fromJson(inputs.version-set).python }}
uses: actions/setup-python@v5
with:
python-version: ${{ fromJson(inputs.version-set).python }}
- name: Build Pulumi Python SDK wheel
run: |
cd sdk/python
sed -i.bak "s/^_VERSION = .*/_VERSION = \"${PYPI_VERSION}\"/g" lib/pulumi/_version.py && rm lib/pulumi/_version.py.bak
make build_package
- name: Upload pulumi.whl
uses: actions/upload-artifact@v4
with:
name: artifacts-python-sdk
path: sdk/python/build/*.whl
retention-days: 1
if-no-files-found: error
build_node_sdk:
name: nodejs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Setup versioning env vars
env:
version: ${{ inputs.version }}
run: |
./scripts/versions.sh | tee -a "${GITHUB_ENV}"
- name: Set up Node ${{ fromJson(inputs.version-set).nodejs }}
uses: actions/setup-node@v4
with:
node-version: ${{ fromJson(inputs.version-set).nodejs }}
cache: yarn
cache-dependency-path: sdk/nodejs/yarn.lock
- name: Install yarn
run: |
npm install -g yarn
# TODO something in `cd sdk/nodejs && make ensure` executes Go
# downloads, which is unfortunate and wasteful in this context.
# When this is fixed the no-op Go command can be removed.
- name: Make no-op Go command to avoid Go builds
run: |
cd sdk/nodejs
mkdir -p bin
# shellcheck disable=SC2230 # need to locate echo binary
ln -s "$(which echo)" bin/go
- name: Ensure installed dependencies
run: |
cd sdk/nodejs
PATH=./bin:$PATH make ensure
- name: Build the Node SDK package
run: |
cd sdk/nodejs
PATH=./bin:$PATH make build_package
- name: Pack the Node SDK
run: |
cd sdk/nodejs/bin
npm pack
- name: Upload pulumi-node-sdk.tgz
uses: actions/upload-artifact@v4
with:
name: artifacts-nodejs-sdk
path: sdk/nodejs/bin/*.tgz
retention-days: 1
if-no-files-found: error