Skip to content

build-commit

build-commit #86

Workflow file for this run

name: build-commit
on:
workflow_dispatch:
inputs:
build_for_arm:
type: boolean
description: "Build for ARM"
required: false
default: false
python_version:
type: string
description: The version of python to use
required: false
default: "3.9"
jobs:
build-commit:
runs-on: ${{ inputs.build_for_arm && 'buildjet-8vcpu-ubuntu-2204-arm' || 'buildjet-8vcpu-ubuntu-2004' }}
timeout-minutes: 30 # Remove for ssh debugging
permissions:
id-token: write
contents: read
steps:
- name: Set platform substring
run: |
if [ "${{ inputs.build_for_arm }}" == "true" ]; then
platform_substring=aarch
else
platform_substring=x86
fi
echo "platform_substring=$platform_substring" >> $GITHUB_ENV
echo "Running on $platform_substring build machines"
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-session-name: build-commit-workflow
role-to-assume: ${{ secrets.ACTIONS_AWS_ROLE_ARN }}
- name: Install uv, rust, python
uses: ./.github/actions/install
with:
python_version: ${{ inputs.python_version }}
- name: Restore cached build artifacts
uses: buildjet/cache@v4
with:
path: ~/target/release
key: ${{ runner.os }}-${{ inputs.build_for_arm && 'arm' || 'x86' }}-cargo-deps-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ inputs.build_for_arm && 'arm' || 'x86' }}-cargo-deps-
- name: Setup uv environment
run: |
uv v
source .venv/bin/activate
uv pip install boto3 packaging
- name: Check if build already exists in AWS S3
run: |
source .venv/bin/activate
wheel_name=$(python .github/ci-scripts/get_wheel_name_from_s3.py ${{ github.sha }} $platform_substring)
if [ "$wheel_name" ]; then
echo "Python wheel for this commit already built and uploaded"
else
echo "No python wheel for this commit found; proceeding with build"
fi
echo "wheel_name=$wheel_name" >> $GITHUB_ENV
- name: Build release wheel
run: |
if [ "$wheel_name" ]; then
echo "Python wheel for this commit already built and uploaded"
exit 0
fi
export CARGO_TARGET_DIR=~/target
source .venv/bin/activate
uv pip install pip maturin boto3
maturin build --release
- name: Upload wheel to AWS S3
run: |
if [ "$wheel_name" ]; then
echo "Python wheel for this commit already built and uploaded"
exit 0
fi
source .venv/bin/activate
wheel_name=$(python .github/ci-scripts/upload_wheel_to_s3.py ${{ github.sha }} $platform_substring ~/target/wheels)
echo "wheel_name=$wheel_name" >> $GITHUB_ENV
- name: Print url of the built wheel to GitHub Actions Summary Page
run: |
url="https://us-west-2.console.aws.amazon.com/s3/object/github-actions-artifacts-bucket?prefix=builds/${{ github.sha }}/$wheel_name"
echo "Output python-release-wheel location:" >> $GITHUB_STEP_SUMMARY
echo "$url" >> $GITHUB_STEP_SUMMARY