Skip to content

Commit a41e046

Browse files
committed
feat: auto-resolve upstream tag, drop Podman, clean up Makefile
- Add scripts/resolve-upstream-tag.sh: resolves Python version to actions/python-versions source tag via authenticated GitHub API - Makefile: PYTHON_VERSION 3.14.4→3.14.5, auto-resolve ACTIONS_PYTHON_VERSIONS - Makefile: drop Podman support (BuildKit --secret requires Docker) - Makefile: export DOCKER_BUILDKIT=1 once, remove inline duplication - Makefile: extract DOCKER_SECRET_FLAGS shared variable (24 lines saved) - Dockerfile: sync default ARGs to 3.14.5-25647354415 Signed-off-by: Adilhusain Shaikh <Adilhusain.Shaikh@ibm.com>
1 parent ff8fc39 commit a41e046

3 files changed

Lines changed: 63 additions & 18 deletions

File tree

Makefile

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
SHELL := /bin/bash
1010
.SHELLFLAGS := -eu -o pipefail -c
1111

12+
# BuildKit is required for --secret mounts (GitHub token forwarding)
13+
export DOCKER_BUILDKIT := 1
14+
1215
ifeq ($(origin V), undefined)
1316
Q := @
1417
else
1518
Q :=
1619
endif
1720

1821
# Versioning
19-
PYTHON_VERSION ?= 3.14.4
20-
ACTIONS_PYTHON_VERSIONS ?= 3.13.3-14344076652
22+
PYTHON_VERSION ?= 3.14.5
23+
# Auto-resolve from upstream releases unless explicitly overridden.
24+
# To pin a specific tag: make ACTIONS_PYTHON_VERSIONS=3.14.4-25113653268 ...
25+
ACTIONS_PYTHON_VERSIONS ?= $(shell ./scripts/resolve-upstream-tag.sh $(PYTHON_VERSION))
2126
POWERSHELL_VERSION ?= v7.6.1
2227
POWERSHELL_NATIVE_VERSION ?= v7.4.0
2328
UBUNTU_VERSION ?= 24.04
@@ -40,13 +45,18 @@ else
4045
ARCH := $(ARCH_RAW)
4146
endif
4247

43-
# Container Engine Detection
44-
CONTAINER_ENGINE := $(shell command -v podman 2>/dev/null || command -v docker)
48+
# Container Engine (Docker required — BuildKit needed for secret mounts)
49+
CONTAINER_ENGINE := $(shell command -v docker)
4550

4651
ifeq ($(strip $(CONTAINER_ENGINE)),)
47-
$(error No container runtime found. Please install `docker` or `podman`)
52+
$(error Docker is required. BuildKit is needed for --secret mounts.)
4853
endif
4954

55+
# Secret flags for Docker BuildKit (forwards GITHUB_TOKEN into the build)
56+
# Empty if GITHUB_TOKEN is not set — the Dockerfile handles missing secrets.
57+
c := ,
58+
DOCKER_SECRET_FLAGS = $(if $(GITHUB_TOKEN),--secret id=github_token$cenv=GITHUB_TOKEN,)
59+
5060
# --- Internal Variables -------------------------------------------------------
5161

5262
BASE_IMAGE := powershell:ubuntu-$(UBUNTU_VERSION)
@@ -83,12 +93,8 @@ $(OUTPUT_DIR)/$(HOST_ARTIFACT_NAME): verify-trivy-version verify-trivy-checksums
8393
@echo "--- Building Python $(PYTHON_VERSION) Image ($(ARCH)) ---"
8494
@echo " Security Gate: CRIT=$(FAIL_ON_CRITICAL) HIGH=$(FAIL_ON_HIGH)"
8595
$(Q)cd python-versions && \
86-
secret_flags=""; \
87-
if [ -n "$${GITHUB_TOKEN:-}" ]; then \
88-
secret_flags="--secret id=github_token,env=GITHUB_TOKEN"; \
89-
fi; \
90-
DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build \
91-
$$secret_flags \
96+
$(CONTAINER_ENGINE) build \
97+
$(DOCKER_SECRET_FLAGS) \
9298
--network=host \
9399
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
94100
--build-arg ACTIONS_PYTHON_VERSIONS=$(ACTIONS_PYTHON_VERSIONS) \
@@ -158,12 +164,8 @@ update-trivy-pins:
158164
powershell: $(PS_PREREQS)
159165
@echo "--- Building PowerShell Base Image ---"
160166
$(Q)cd $(PS_DIR) && \
161-
secret_flags=""; \
162-
if [ -n "$${GITHUB_TOKEN:-}" ]; then \
163-
secret_flags="--secret id=github_token,env=GITHUB_TOKEN"; \
164-
fi; \
165167
$(CONTAINER_ENGINE) build \
166-
$$secret_flags \
168+
$(DOCKER_SECRET_FLAGS) \
167169
--network=host \
168170
--build-arg POWERSHELL_VERSION=$(POWERSHELL_VERSION) \
169171
--build-arg POWERSHELL_NATIVE_VERSION=$(POWERSHELL_NATIVE_VERSION) \

python-versions/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
ARG UBUNTU_VERSION=24.04
33
ARG BASE_IMAGE=powershell:ubuntu-${UBUNTU_VERSION}
44
ARG TARGETARCH
5-
ARG PYTHON_VERSION=3.13.3
6-
ARG ACTIONS_PYTHON_VERSIONS=3.13.3-14344076652
5+
ARG PYTHON_VERSION=3.14.5
6+
ARG ACTIONS_PYTHON_VERSIONS=3.14.5-25647354415
77
ARG TRIVY_VERSION=v0.70.0 # default should match .trivyversion in repo root
88

99
# ================= BUILDER STAGE =====================

scripts/resolve-upstream-tag.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# ------------------------------------------------------------------------------
3+
# resolve-upstream-tag.sh
4+
#
5+
# Resolves a Python version (e.g., "3.14.5" or "3.15.0-beta.1") to the
6+
# corresponding source-code tag from the actions/python-versions upstream
7+
# repository by querying its GitHub releases.
8+
#
9+
# Usage:
10+
# ./scripts/resolve-upstream-tag.sh <python-version>
11+
#
12+
# Examples:
13+
# ./scripts/resolve-upstream-tag.sh 3.14.5 # → 3.14.5-25647354415
14+
# ./scripts/resolve-upstream-tag.sh 3.15.0-beta.1 # → 3.15.0-beta.1-25533511631
15+
#
16+
# Requires: curl, jq, and gh (GitHub CLI). Uses gh's stored token for auth.
17+
# ------------------------------------------------------------------------------
18+
set -euo pipefail
19+
20+
if [ $# -ne 1 ]; then
21+
echo "Usage: $0 <python-version>" >&2
22+
exit 1
23+
fi
24+
25+
PYTHON_VERSION="$1"
26+
UPSTREAM_REPO="actions/python-versions"
27+
28+
# Retrieve the GitHub token from gh CLI for authenticated curl requests
29+
GH_TOKEN="$(gh auth token)"
30+
31+
# Query the upstream releases API and find the release whose name
32+
# matches the requested Python version exactly.
33+
TAG_NAME=$(curl -sL -H "Authorization: Bearer $GH_TOKEN" \
34+
"https://api.github.com/repos/${UPSTREAM_REPO}/releases" \
35+
| jq -r --arg ver "$PYTHON_VERSION" \
36+
'[.[] | select(.name == $ver)] | first | .tag_name // empty')
37+
38+
if [ -z "$TAG_NAME" ]; then
39+
echo "ERROR: Could not find upstream release matching Python version '$PYTHON_VERSION' in $UPSTREAM_REPO" >&2
40+
exit 1
41+
fi
42+
43+
echo "$TAG_NAME"

0 commit comments

Comments
 (0)