Skip to content

Action Update: Bump docker/build-push-action from 5.1.0 to 5.3.0 (#19) #95

Action Update: Bump docker/build-push-action from 5.1.0 to 5.3.0 (#19)

Action Update: Bump docker/build-push-action from 5.1.0 to 5.3.0 (#19) #95

Workflow file for this run

name: Build PyPy
on:
push:
branches:
- '**'
paths:
- 'builder/**'
- '.github/workflows/build-pypy.yml'
workflow_dispatch:
permissions:
contents: read
packages: write
env:
ALPINE_VERSION: 3.19
BUILDER_IMAGE_TAG: ghcr.io/cyb3r-jak3/alpine-pypy-builder-workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Prep:
runs-on: ubuntu-latest
name: Prep Docker Container
steps:
- uses: actions/checkout@v4
- name: Login To GitHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/[email protected]
with:
context: "builder/"
tags: ${{ env.BUILDER_IMAGE_TAG }}:${{ env.ALPINE_VERSION }}-${{ github.sha }}
build-args: |
BUILD_IMAGE=ghcr.io/cyb3r-jak3/alpine-pypy:2.7-7.3.14-3.19
cache-to: type=gha,mode=max,scope=buildx-alpine-pypy-workflow-builder:${{ env.ALPINE_VERSION }}
cache-from: type=gha,scope=buildx-alpine-pypy-workflow-builder:${{ env.ALPINE_VERSION }}
platforms: linux/amd64, linux/arm64
push: true
Build:
runs-on: ${{ matrix.RUNNER }}
name: Run Container
needs: Prep
strategy:
fail-fast: true
matrix:
PYPY_BASE: ["2.7", "3.9", "3.10"]
PYPY_VERSION: ["7.3.15"]
RUNNER: ["self-hosted", "ubuntu-latest"]
steps:
- name: Setup Platforms
env:
RUNS_ON: ${{ matrix.RUNNER }}
shell: python
run: |
import os
if os.environ["RUNS_ON"] == "self-hosted":
with open(os.environ['GITHUB_ENV'], 'a') as fh:
print('ARCH=arm64', file=fh)
print('PYPY_ARCH=aarch64', file=fh)
else:
with open(os.environ['GITHUB_ENV'], 'a') as fh:
print('ARCH=amd64', file=fh)
print('PYPY_ARCH=x86_64', file=fh)
- name: Check if file and signature already exists
id: file-check
shell: python
run: |
import os
import requests
base_url = "https://pypy.cyberjake.xyz/pypy/${{ matrix.PYPY_BASE }}/pypy${{ matrix.PYPY_BASE }}-v${{ matrix.PYPY_VERSION }}-linux-${{ env.PYPY_ARCH }}-alpine.tar.bz2"
file_resp = requests.head(base_url)
signature_resp = requests.head(f"{base_url}.sig")
if file_resp.status_code == 404 or signature_resp.status_code == 404:
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print('STATUS=404', file=fh)
- name: Login To GitHub
if: steps.file-check.outputs.STATUS == 404
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
if: steps.file-check.outputs.STATUS == 404
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: steps.file-check.outputs.STATUS == 404
uses: docker/setup-buildx-action@v3
- name: Run Build
if: steps.file-check.outputs.STATUS == 404
run: |
PYPY_SHA256SUM=$(curl -s https://api.cyberjake.xyz/pypy/checksums/pypy${{ matrix.PYPY_BASE }}-v${{ matrix.PYPY_VERSION }}-src.tar.bz2 | jq --raw-output .results[0].checksum)
echo "${PYPY_SHA256SUM}"
docker run --platform linux/${{ env.ARCH }} -v $(pwd)/tmp:/tmp -e PYPY_BASE=${{ matrix.PYPY_BASE }} -e PYPY_VERSION=${{ matrix.PYPY_VERSION }} -e PYPY_SHA256SUM="${PYPY_SHA256SUM}" ${{ env.BUILDER_IMAGE_TAG }}:${{ env.ALPINE_VERSION }}-${{ github.sha }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
if: steps.file-check.outputs.STATUS == 404
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
trust_level: 5
- name: Prep files
if: steps.file-check.outputs.STATUS == 404
run: |
wget --quiet -O sign.py https://raw.githubusercontent.com/Cyb3r-Jak3/docker-alpine-pypy/${{ github.sha }}/.github/sign.py
mkdir output
mv ./tmp/usession-release-pypy${{ matrix.PYPY_BASE }}-v${{ matrix.PYPY_VERSION }}-*/build/**.tar.bz2 ./output/pypy${{ matrix.PYPY_BASE }}-v${{ matrix.PYPY_VERSION }}-linux-${{ env.PYPY_ARCH }}-alpine.tar.bz2
find ./output/ -type f -exec python3 sign.py {} \;
- name: Upload PyPy to Artifacts
if: steps.file-check.outputs.STATUS == 404
# Leave with v3 so we can use the same name for the artifact
uses: actions/upload-artifact@v3
with:
name: pypy-${{ env.ARCH }}
path: ./output
- name: Clean files
if: steps.file-check.outputs.STATUS == 404
run: |
rm -rf output/
rm -rf tmp/