Skip to content

build-commit

build-commit #62

Workflow file for this run

name: build-commit
on:
workflow_dispatch:
workflow_call:
secrets:
ACTIONS_AWS_ROLE_ARN:
description: The ARN of the AWS role to assume
required: true
outputs:
wheel:
description: The wheel file that was built
value: ${{ jobs.build-commit.outputs.wheel }}
jobs:
build-commit:
runs-on: buildjet-8vcpu-ubuntu-2004
timeout-minutes: 15 # Remove for ssh debugging
permissions:
id-token: write
contents: read
outputs:
wheel: ${{ steps.upload.outputs.wheel }}
steps:
- 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 rust + uv + python
uses: ./.github/actions/install
- name: Restore cached build artifacts
uses: buildjet/cache@v4
with:
path: ~/target
key: ${{ runner.os }}-cargo-deps-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-deps-
- name: Check if build already exists in AWS S3
run: |
RESULT=$(aws s3 ls s3://github-actions-artifacts-bucket/builds/${{ github.sha }}/ | wc -l)
if [ "$RESULT" -gt 1 ]; then
echo "Error: More than one artifact found. Failing the job."
exit 1
elif [ "$RESULT" -eq 0 ]; then
echo "COMMIT_BUILT=0" >> $GITHUB_ENV
echo "No artifacts found; will proceed with building a new wheel"
elif [ "$RESULT" -eq 1 ]; then
echo "COMMIT_BUILT=1" >> $GITHUB_ENV
echo "Commit already built; reusing existing wheel"
fi
- name: Build release wheel
run: |
if [ "$COMMIT_BUILT" -eq 1 ]; then
echo "Commit already built"
exit 0
fi
export CARGO_TARGET_DIR=~/target
uv v
source .venv/bin/activate
uv pip install pip maturin boto3
maturin build --release
- name: Upload wheel to AWS S3
id: upload
run: |
if [ "$COMMIT_BUILT" -eq 1 ]; then
echo "Commit already built"
wheel=$(aws s3 ls s3://github-actions-artifacts-bucket/builds/${{ github.sha }}/ | awk '{print $4}')
echo "wheel=$wheel" >> $GITHUB_OUTPUT
else
count=$(ls ~/target/wheels/*.whl 2> /dev/null | wc -l)
if [ "$count" -gt 1 ]; then
echo "Found more than 1 wheel"
exit 1
elif [ "$count" -eq 0 ]; then
echo "Found no wheels"
exit 1
fi
for file in ~/target/wheels/*.whl; do
aws s3 cp $file s3://github-actions-artifacts-bucket/builds/${{ github.sha }}/ --acl public-read --no-progress;
file_basename=$(basename $file)
echo "wheel=$file_basename" >> $GITHUB_OUTPUT
done
fi
echo "Output python-release-wheel location:" >> $GITHUB_STEP_SUMMARY
echo "https://us-west-2.console.aws.amazon.com/s3/buckets/github-actions-artifacts-bucket?prefix=builds/${{ github.sha }}/" >> $GITHUB_STEP_SUMMARY