Skip to content

Commit f630173

Browse files
authored
Merge pull request #2 from fok666/feature/github-pipelines
Feature/GitHub pipelines
2 parents 8d33ec1 + 40e0dea commit f630173

4 files changed

Lines changed: 215 additions & 35 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ updates:
99
directory: "/" # Location of package manifests
1010
schedule:
1111
interval: "weekly"
12+
- package-ecosystem: "github-actions" # See documentation for possible values
13+
directory: "/" # Location of package manifests
14+
schedule:
15+
interval: "weekly"
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: Build and Release Multi-Arch Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
jobs:
19+
build-amd64:
20+
name: Build AMD64 - Python ${{ matrix.python-version }}
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
strategy:
26+
matrix:
27+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Log in to Container Registry
36+
if: github.event_name != 'pull_request'
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract metadata
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
tags: |
49+
type=raw,value=python${{ matrix.python-version }}-amd64-latest,enable={{is_default_branch}}
50+
type=ref,event=branch,suffix=-python${{ matrix.python-version }}-amd64
51+
type=ref,event=pr,suffix=-python${{ matrix.python-version }}-amd64
52+
type=semver,pattern={{version}},suffix=-python${{ matrix.python-version }}-amd64
53+
type=semver,pattern={{major}}.{{minor}},suffix=-python${{ matrix.python-version }}-amd64
54+
type=sha,suffix=-python${{ matrix.python-version }}-amd64
55+
56+
- name: Build and push AMD64 image
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: .
60+
platforms: linux/amd64
61+
build-args: |
62+
PYTHON_VERSION=${{ matrix.python-version }}
63+
push: ${{ github.event_name != 'pull_request' }}
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}
66+
cache-from: type=gha,scope=amd64-${{ matrix.python-version }}
67+
cache-to: type=gha,mode=max,scope=amd64-${{ matrix.python-version }}
68+
69+
build-arm64:
70+
name: Build ARM64 - Python ${{ matrix.python-version }}
71+
runs-on: ubuntu-24.04-arm64
72+
permissions:
73+
contents: read
74+
packages: write
75+
strategy:
76+
matrix:
77+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Docker Buildx
83+
uses: docker/setup-buildx-action@v3
84+
85+
- name: Log in to Container Registry
86+
if: github.event_name != 'pull_request'
87+
uses: docker/login-action@v3
88+
with:
89+
registry: ${{ env.REGISTRY }}
90+
username: ${{ github.actor }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Extract metadata
94+
id: meta
95+
uses: docker/metadata-action@v5
96+
with:
97+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
98+
tags: |
99+
type=raw,value=python${{ matrix.python-version }}-arm64-latest,enable={{is_default_branch}}
100+
type=ref,event=branch,suffix=-python${{ matrix.python-version }}-arm64
101+
type=ref,event=pr,suffix=-python${{ matrix.python-version }}-arm64
102+
type=semver,pattern={{version}},suffix=-python${{ matrix.python-version }}-arm64
103+
type=semver,pattern={{major}}.{{minor}},suffix=-python${{ matrix.python-version }}-arm64
104+
type=sha,suffix=-python${{ matrix.python-version }}-arm64
105+
106+
- name: Build and push ARM64 image
107+
uses: docker/build-push-action@v5
108+
with:
109+
context: .
110+
platforms: linux/arm64
111+
build-args: |
112+
PYTHON_VERSION=${{ matrix.python-version }}
113+
push: ${{ github.event_name != 'pull_request' }}
114+
tags: ${{ steps.meta.outputs.tags }}
115+
labels: ${{ steps.meta.outputs.labels }}
116+
cache-from: type=gha,scope=arm64-${{ matrix.python-version }}
117+
cache-to: type=gha,mode=max,scope=arm64-${{ matrix.python-version }}
118+
119+
create-manifest:
120+
name: Create Multi-Arch Manifest - Python ${{ matrix.python-version }}
121+
runs-on: ubuntu-latest
122+
needs: [build-amd64, build-arm64]
123+
if: github.event_name != 'pull_request'
124+
permissions:
125+
contents: read
126+
packages: write
127+
strategy:
128+
matrix:
129+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
130+
steps:
131+
- name: Log in to Container Registry
132+
uses: docker/login-action@v3
133+
with:
134+
registry: ${{ env.REGISTRY }}
135+
username: ${{ github.actor }}
136+
password: ${{ secrets.GITHUB_TOKEN }}
137+
138+
- name: Create and push manifest for latest
139+
if: github.ref == 'refs/heads/main'
140+
run: |
141+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-latest \
142+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-amd64-latest \
143+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-arm64-latest
144+
145+
- name: Create and push manifest for tags
146+
if: startsWith(github.ref, 'refs/tags/')
147+
run: |
148+
TAG_VERSION=${GITHUB_REF#refs/tags/}
149+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }} \
150+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }}-amd64 \
151+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }}-arm64
152+
153+
create-release:
154+
name: Create GitHub Release
155+
runs-on: ubuntu-latest
156+
needs: [create-manifest]
157+
if: startsWith(github.ref, 'refs/tags/')
158+
permissions:
159+
contents: write
160+
steps:
161+
- name: Checkout repository
162+
uses: actions/checkout@v4
163+
164+
- name: Create Release
165+
uses: softprops/action-gh-release@v1
166+
with:
167+
generate_release_notes: true
168+
body: |
169+
## Multi-Arch Docker Images
170+
171+
Images are available for Python 3.10, 3.11, 3.12, 3.13, and 3.14 on both AMD64 and ARM64 architectures.
172+
173+
### Usage
174+
175+
Pull a specific Python version:
176+
```bash
177+
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python3.14
178+
```
179+
180+
The images support both AMD64 and ARM64 architectures automatically.
181+
182+
### Available Tags
183+
- `${{ github.ref_name }}-python3.10` (multi-arch)
184+
- `${{ github.ref_name }}-python3.11` (multi-arch)
185+
- `${{ github.ref_name }}-python3.12` (multi-arch)
186+
- `${{ github.ref_name }}-python3.13` (multi-arch)
187+
- `${{ github.ref_name }}-python3.14` (multi-arch)

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) Microsoft Corporation
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.

readme.md

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Build AWS Lambda deployment packages and layers for multiple Python versions (3.10+) and architectures (x86_64/arm64).
44

5+
[![Dependabot Updates](https://github.com/fok666/lambda-python-layer/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/fok666/lambda-python-layer/actions/workflows/dependabot/dependabot-updates) [![Build and Release Multi-Arch Docker Images](https://github.com/fok666/lambda-python-layer/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/fok666/lambda-python-layer/actions/workflows/build-and-release.yml)
6+
7+
Inspired by [LambdaZipper](https://github.com/tiivik/LambdaZipper)
8+
59
## Features
610

711
- 🐍 **Multiple Python versions**: Support for Python 3.10, 3.11, 3.12, 3.13, and 3.14 (default)
@@ -309,41 +313,6 @@ docker run --rm \
309313
lambda-zipper:custom numpy
310314
```
311315

312-
## Migration Guide
313-
314-
### Migrating from Previous Versions
315-
316-
**Old behavior** (required explicit flags):
317-
```bash
318-
./build-multiarch.sh --requirements requirements.txt --python 3.13
319-
```
320-
321-
**New behavior** (smart defaults):
322-
```bash
323-
./build-multiarch.sh # Uses requirements.txt and Python 3.14 by default
324-
```
325-
326-
**Key Changes:**
327-
- Default Python version changed from 3.13 → 3.14
328-
- `-r` or `--requirements` flag now optional (defaults to `requirements.txt`)
329-
- Single combined archive is now the default (use `--individual` for old behavior)
330-
- Both architectures built by default (use `--skip-arm64` or `--skip-x86` to build only one)
331-
332-
### Updating Existing Scripts
333-
334-
If you have scripts using the old syntax, they will continue to work. However, you can simplify them:
335-
336-
```bash
337-
# Old way (still works)
338-
./build-multiarch.sh --requirements requirements.txt --python 3.13
339-
340-
# New simplified way (if using defaults)
341-
./build-multiarch.sh --python 3.13
342-
343-
# Or just use all defaults
344-
./build-multiarch.sh
345-
```
346-
347316
## Output File Naming
348317

349318
Archives are named with the following pattern:

0 commit comments

Comments
 (0)