pulumi/.github/workflows/build.yml

283 lines
8.9 KiB
YAML

name: Builds CLI and SDK binaries.
on:
workflow_call:
inputs:
go-version:
description: 'Version of the Go toolchain for the build'
default: '1.19.x'
required: false
type: string
python-version:
description: 'Version of the Python toolchain for the build'
default: '3.9.x'
required: false
type: string
node-version:
description: 'Version of the Node toolchain for the build'
default: '14.x'
required: false
type: string
dotnet-version:
description: 'Version of the .NET toolchain for the build'
default: '6.0.x'
required: false
type: string
goreleaser-flags:
description: 'Extra command-line flags to pass to goreleaser'
required: true
type: string
enable-coverage:
description: 'Builds executables with coverage analysis enabled'
default: false
required: false
type: boolean
macos-build-platform:
description: 'Platform to use when building macOS binaries'
default: macos-latest
required: false
type: string
secrets: {}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOTNET_ROLL_FORWARD: "Major"
jobs:
build_pulumi_go_binaries:
strategy:
matrix:
include:
- platform: ${{ inputs.macos-build-platform }}
os: darwin
arch: amd64
artifactName: pulumi-macOS-X64
- platform: ${{ inputs.macos-build-platform }}
os: darwin
arch: arm64
artifactName: pulumi-macOS-ARM64
- platform: ubuntu-latest
os: linux
arch: amd64
artifactName: pulumi-Linux-X64
- platform: ubuntu-latest
os: linux
arch: arm64
artifactName: pulumi-Linux-ARM64
- platform: ubuntu-latest
os: windows
arch: amd64
artifactName: pulumi-Windows-X64
fail-fast: false
name: Build Pulumi Go binaries
runs-on: ${{ matrix.platform }}
steps:
- name: Enable code coverage
run: |
echo "PULUMI_TEST_COVERAGE_PATH=$(pwd)/coverage" >> $GITHUB_ENV
if: ${{ inputs.enable-coverage }}
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Fetch Tags
run: |
git fetch --quiet --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.7.1
with:
repo: pulumi/pulumictl
tag: v0.0.32
cache: enable
- name: Set up Go ${{ inputs.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ inputs.go-version }}
check-latest: true
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Cache
uses: actions/cache@v2
id: go-cache
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: build.yml/go/${{ matrix.os }}/${{ matrix.arch }}/${{ hashFiles('*/go.sum') }}
restore-keys: |
build.yml/go/${{ matrix.os }}/${{ matrix.arch }}
- name: Download versions.txt
uses: actions/download-artifact@v2
with:
name: versions.txt
path: versions
- name: Setup versioning env vars
run: |
cat versions/versions.txt | tee $GITHUB_ENV
rm -rf versions
- name: Run GoReleaser to build Go Pulumi binaries
uses: goreleaser/goreleaser-action@v2
with:
version: latest
distribution: goreleaser-pro
args: build -f .goreleaser.build.yml --single-target ${{ inputs.goreleaser-flags }}
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
- name: Upload ${{ matrix.artifactName }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifactName }}
path: goreleaser/*/*
retention-days: 2
build_python_sdk:
name: Build Pulumi Python SDK wheel
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Fetch Tags
run: |
git fetch --quiet --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.7.1
with:
repo: pulumi/pulumictl
tag: v0.0.32
cache: enable
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ inputs.python-version }}
cache: pip
cache-dependency-path: sdk/python/requirements.txt
- name: Download versions.txt
uses: actions/download-artifact@v2
with:
name: versions.txt
path: versions
- name: Setup versioning env vars
run: |
cat versions/versions.txt | tee $GITHUB_ENV
rm -rf versions
- name: Build Pulumi Python SDK wheel
run: |
# TODO unify with sdk/python/Makefile once that does not use pipenv
cp README.md sdk/python/lib
cd sdk/python/lib
sed -i.bak "s/\${VERSION}/$PYPI_VERSION/g" setup.py
rm setup.py.bak
python3 -m venv venv
source venv/bin/activate
python -m pip install wheel
python setup.py build bdist_wheel --python-tag py3
- name: Upload pulumi.whl
uses: actions/upload-artifact@v2
with:
name: pulumi.whl
path: sdk/python/lib/dist/*.whl
retention-days: 2
build_node_sdk:
name: Build Pulumi Node SDK tarball
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Fetch Tags
run: |
git fetch --quiet --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.7.1
with:
repo: pulumi/pulumictl
tag: v0.0.32
cache: enable
- name: Set up Node ${{ inputs.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache-dependency-path: sdk/nodejs/package.json
- 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
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@v2
with:
name: pulumi-node-sdk.tgz
path: sdk/nodejs/bin/*.tgz
retention-days: 2
build_dotnet_sdk:
name: Build Pulumi .NET SDK NuGet packages
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Fetch Tags
run: |
git fetch --quiet --prune --unshallow --tags
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.7.1
with:
repo: pulumi/pulumictl
tag: v0.0.32
cache: enable
- name: Set up DotNet ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Download versions.txt
uses: actions/download-artifact@v2
with:
name: versions.txt
path: versions
- name: Setup versioning env vars
run: |
cat versions/versions.txt | tee $GITHUB_ENV
rm -rf versions
- name: Build the .NET SDK package
run: |
cd sdk/dotnet
dotnet build --configuration Release dotnet.sln /p:Version=$DOTNET_VERSION
- name: Pack the .NET SDK package
run: |
cd sdk/dotnet
dotnet pack --configuration Release --output nupkgs dotnet.sln /p:Version=$DOTNET_VERSION
- name: Upload the NuGet packages
uses: actions/upload-artifact@v2
with:
name: pulumi-nuget-packages
path: sdk/dotnet/nupkgs/*.nupkg
retention-days: 2