feature/lambda python for amazonlinux2 #23
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release Multi-Arch Docker Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-amd64: | |
| name: Build AMD64 - Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Determine Dockerfile | |
| id: dockerfile | |
| run: | | |
| if [[ "${{ matrix.python-version }}" == "3.10" || "${{ matrix.python-version }}" == "3.11" ]]; then | |
| echo "path=Dockerfile.al2" >> $GITHUB_OUTPUT | |
| else | |
| echo "path=Dockerfile.al2023" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Log in to Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=python${{ matrix.python-version }}-amd64-latest,enable={{is_default_branch}} | |
| type=ref,event=branch,suffix=-python${{ matrix.python-version }}-amd64 | |
| type=ref,event=pr,suffix=-python${{ matrix.python-version }}-amd64 | |
| type=semver,pattern=v{{version}},suffix=-python${{ matrix.python-version }}-amd64 | |
| type=semver,pattern=v{{major}}.{{minor}},suffix=-python${{ matrix.python-version }}-amd64 | |
| type=sha,suffix=-python${{ matrix.python-version }}-amd64 | |
| - name: Build and push AMD64 image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ steps.dockerfile.outputs.path }} | |
| platforms: linux/amd64 | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=amd64-${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=amd64-${{ matrix.python-version }} | |
| build-arm64: | |
| name: Build ARM64 - Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Determine Dockerfile | |
| id: dockerfile | |
| run: | | |
| if [[ "${{ matrix.python-version }}" == "3.10" || "${{ matrix.python-version }}" == "3.11" ]]; then | |
| echo "path=Dockerfile.al2" >> $GITHUB_OUTPUT | |
| else | |
| echo "path=Dockerfile.al2023" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Log in to Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=python${{ matrix.python-version }}-arm64-latest,enable={{is_default_branch}} | |
| type=ref,event=branch,suffix=-python${{ matrix.python-version }}-arm64 | |
| type=ref,event=pr,suffix=-python${{ matrix.python-version }}-arm64 | |
| type=semver,pattern=v{{version}},suffix=-python${{ matrix.python-version }}-arm64 | |
| type=semver,pattern=v{{major}}.{{minor}},suffix=-python${{ matrix.python-version }}-arm64 | |
| type=sha,suffix=-python${{ matrix.python-version }}-arm64 | |
| - name: Build and push ARM64 image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ steps.dockerfile.outputs.path }} | |
| platforms: linux/arm64 | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=arm64-${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=arm64-${{ matrix.python-version }} | |
| create-manifest: | |
| name: Create Multi-Arch Manifest - Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| needs: [build-amd64, build-arm64] | |
| if: github.event_name != 'pull_request' | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push manifest for latest | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-latest \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-amd64-latest \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-arm64-latest | |
| - name: Create and push manifest for tags | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/} | |
| docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }} \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }}-amd64 \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }}-arm64 | |
| create-release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [create-manifest] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| body: | | |
| ## Multi-Arch Docker Images | |
| Images are available for Python 3.10, 3.11, 3.12, 3.13, and 3.14 on both AMD64 and ARM64 architectures. | |
| ### Usage | |
| Pull a specific Python version: | |
| ```bash | |
| docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python3.14 | |
| ``` | |
| The images support both AMD64 and ARM64 architectures automatically. | |
| ### Available Tags | |
| - `${{ github.ref_name }}-python3.10` (multi-arch) | |
| - `${{ github.ref_name }}-python3.11` (multi-arch) | |
| - `${{ github.ref_name }}-python3.12` (multi-arch) | |
| - `${{ github.ref_name }}-python3.13` (multi-arch) | |
| - `${{ github.ref_name }}-python3.14` (multi-arch) |