-
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (89 loc) · 3.71 KB
/
Copy pathbuild-version.yml
File metadata and controls
101 lines (89 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build Python Version
on:
workflow_call:
inputs:
version:
description: "Specific version (major.minor.patch[suffix]) of Python to build"
required: true
type: string
tag:
description: "Version tag to apply to Docker image (e.g. 3.14, 3.14j)"
required: true
type: string
pyenv_version:
description: "The pyenv version to use when building the builder-base stage"
required: true
type: string
jobs:
build:
name: Build Python ${{ inputs.version }} (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Github Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sanitize platform name
id: platform
run: echo "name=$(echo '${{ matrix.platform }}' | tr '/' '-')" >> $GITHUB_OUTPUT
- name: Build and push platform image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
target: python-builder
platforms: ${{ matrix.platform }}
push: ${{ github.ref == 'refs/heads/main' }}
cache-to: type=inline
cache-from: |
type=registry,ref=ghcr.io/python-discord/python-builds:builder-base
type=registry,ref=ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.platform.outputs.name }}
labels: |
org.opencontainers.image.source=https://github.com/python-discord/python-builds
org.opencontainers.image.description="Python ${{ inputs.version }} Docker image maintained by Python Discord."
org.opencontainers.image.licenses=MIT
tags: |
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.platform.outputs.name }}
build-args: |
PYTHON_VERSION=${{ inputs.version }}
PYENV_VERSION=${{ inputs.pyenv_version }}
merge:
name: Merge ${{ inputs.version }} manifests
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Get Git commit short SHA
id: git-sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Login to Github Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-platform manifest
run: |
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.source=https://github.com/python-discord/python-builds" \
--annotation "index:org.opencontainers.image.description=Python ${{ inputs.version }} Docker image maintained by Python Discord." \
--annotation "index:org.opencontainers.image.licenses=MIT" \
--tag ghcr.io/python-discord/python-builds:${{ inputs.tag }} \
--tag ghcr.io/python-discord/python-builds:${{ inputs.version }} \
--tag ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.git-sha.outputs.sha }} \
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-linux-amd64 \
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-linux-arm64