Skip to content

Build and upload Python 3.8.18 #78

Build and upload Python 3.8.18

Build and upload Python 3.8.18 #78

name: Build and upload Python runtime
run-name: "Build and upload Python ${{ inputs.python_version }}${{ inputs.dry_run && ' (dry run)' || '' }}"
on:
workflow_dispatch:
# TODO: Allow controlling which stack's binaries to build?
inputs:
python_version:
description: "The Python version to build, specified as X.Y.Z"
type: string
required: true
dry_run:
description: "Skip deploying to S3 (e.g. for testing)"
type: boolean
default: false
required: false
permissions:
contents: read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "us-east-1"
S3_BUCKET: "heroku-buildpack-python"
# Unfortunately these jobs cannot be easily written as a matrix since `matrix.exclude` does not
# support expression syntax, and the `inputs` context is not available inside the job `if` key.
jobs:
heroku-20:
runs-on: pub-hk-ubuntu-22.04-xlarge
env:
STACK_VERSION: "20"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Docker image
run: docker build --platform="linux/amd64" --pull --tag buildenv --build-arg=STACK_VERSION builds/
- name: Build and package Python runtime
run: docker run --rm --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}"
- name: Upload Python runtime archive to S3
if: (!inputs.dry_run)
run: aws s3 sync ./upload "s3://${S3_BUCKET}"
heroku-22:
# On Heroku-22 we only support Python 3.9+.
if: (!startsWith(inputs.python_version,'3.8.'))
runs-on: pub-hk-ubuntu-22.04-xlarge
env:
STACK_VERSION: "22"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Docker image
run: docker build --platform="linux/amd64" --pull --tag buildenv --build-arg=STACK_VERSION builds/
- name: Build and package Python runtime
run: docker run --rm --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}"
- name: Upload Python runtime archive to S3
if: (!inputs.dry_run)
run: aws s3 sync ./upload "s3://${S3_BUCKET}"
heroku-24:
# On Heroku-24 we only support Python 3.12+.
if: (startsWith(inputs.python_version,'3.12.'))
strategy:
fail-fast: false
matrix:
architecture: ["amd64", "arm64"]
runs-on: "${{ matrix.architecture == 'arm64' && 'pub-hk-ubuntu-22.04-arm-large' || 'pub-hk-ubuntu-22.04-xlarge' }}"
env:
STACK_VERSION: "24"
steps:
- name: Checkout
uses: actions/checkout@v4
# The beta Arm64 runners don't yet ship with the normal installed tools.
- name: Install Docker and AWS CLI (ARM64 only)
if: matrix.architecture == 'arm64'
run: |
sudo apt-get update --error-on=any
sudo apt-get install -y --no-install-recommends acl docker.io docker-buildx unzip
sudo usermod -aG docker $USER
sudo setfacl --modify user:$USER:rw /var/run/docker.sock
curl https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -o awscliv2.zip
unzip awscliv2.zip
sudo ./aws/install
rm -rf awscliv2.zip ./aws/
- name: Build Docker image
run: docker build --platform="linux/${{ matrix.architecture }}" --pull --tag buildenv --build-arg=STACK_VERSION builds/
- name: Build and package Python runtime
run: docker run --rm --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}"
- name: Upload Python runtime archive to S3
if: (!inputs.dry_run)
run: aws s3 sync ./upload "s3://${S3_BUCKET}"