Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzyx committed Apr 24, 2024
1 parent 1136b87 commit 8d945f5
Show file tree
Hide file tree
Showing 8 changed files with 376 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/_build-and-cache-by-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: "🎯 Step: Build and cache"
on:
workflow_call:
inputs:
package-name:
required: true
type: string
package-version:
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build-and-cache
cancel-in-progress: true

# Variables available to all jobs defined in this file
env:
DOCKER_BUILDKIT: 1
REGISTRY: ${{ vars.REGISTRY }}

# Declare default permissions as read only.
permissions: read-all

jobs:
compile_ubuntu:
runs-on: ubuntu-latest
name: "📦 Compile for Ubuntu ${{ matrix.Release }} (${{ matrix.Arch }})"
strategy:
fail-fast: false
matrix:
Release:
- "20.04"
- "22.04"
Arch:
- amd64
- arm64

container:
image: "ghcr.io/northwood-labs/package-builder/ubuntu-v${{ matrix.Release }}:latest"
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
options: --privileged --platform "linux/${{ matrix.Arch }}"

steps:
- name: Git clone
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
ref: ${{ github.base_ref }}

- name: Compile the software from source
working-directory: packages/${{ inputs.package-name }}
run: |
# Run the compile script for Ubuntu 22.04
# Variables are defined by the Docker container this is running in.
bash "./compile-${OS_DIST}-${OS_DIST_VER}.sh"
- name: Package the compiled software
working-directory: packages/${{ inputs.package-name }}
run: |
# Decode the contents into files.
echo -n "${GPG_KEY_B64}" | base64 --decode > 3C7658F0.asc
echo -n "${RSA_KEY_B64}" | base64 --decode > signing.pem
mkdir -p ./dist
nfpm package --config nfpm-${OS_DIST}-${OS_DIST_VER}.yaml --packager deb --target ./dist
- name: Cache the packages
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: cache-packages
with:
key: "${{ inputs.package-name }}-${{ inputs.package-version }}-${OS_DIST}-${OS_DIST_VER}-${{ matrix.Arch }}"
path: packages/${{ inputs.package-name }}/dist
114 changes: 114 additions & 0 deletions .github/workflows/build-python3.12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

################################################################################
# DO NOT EDIT THIS FILE!
#
# 1. Edit the *.gotmpl.yml files instead.
# 2. go run generate-workflow.go -t _download-and-package.gotmpl.yml -p python3.12 -r 'python/cpython' -c '00 13 * * *'
################################################################################

name: "📦 Build python3.12"
on:
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/build-python3.12.yml"
- "packages/python3.12/**"
pull_request:
branches: [main]
paths:
- ".github/workflows/build-python3.12.yml"
- "packages/python3.12/**"
schedule:
- cron: "00 13 * * *"

defaults:
run:
shell: bash

env:
DOCKER_BUILDKIT: 1
REGISTRY: ${{ vars.REGISTRY }}

permissions: read-all

jobs:
lookup:
runs-on: ubuntu-latest
name: Lookup current version
permissions:
packages: write
contents: read
strategy:
fail-fast: false

container:
image: ghcr.io/northwood-labs/package-builder/ubuntu-v22.04:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

outputs:
cache_hit: ${{ steps.check.outputs.cache-hit }}
package_version: ${{ steps.lookup_version.outputs.package_version }}

steps:
- name: Lookup latest version of package
id: lookup_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "package_version=$(download-asset latest-tag -r 'python/cpython' -s)" >> $GITHUB_OUTPUT
- name: Check to see if we've already built this version
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: check
with:
key: "python-${{ steps.lookup_version.outputs.package_version }}"
path: "packages/python/dist"
lookup-only: true

build:
if: needs.lookup.outputs.cache_hit != 'true'
needs: lookup
name: "📦 Build and cache"
uses: northwood-labs/package-building/.github/workflows/_build-and-cache-by-platform.yml@main
secrets: inherit
with:
package-name: "python"
package-version: ${{ needs.lookup.outputs.package_version }}

upload:
if: needs.lookup.outputs.cache_hit != 'true'
needs: build
name: Upload to S3
uses: northwood-labs/package-building/.github/workflows/upload-to-s3.yml@main
secrets: inherit
with:
package-name: "python"
package-version: ${{ needs.lookup.outputs.package_version }}

metadata_rpm:
if: needs.lookup.outputs.cache_hit != 'true'
needs: upload
name: RPM metadata
uses: northwood-labs/package-building/.github/workflows/generate-rpm-meta.yml@main
secrets: inherit

metadata_deb:
if: needs.lookup.outputs.cache_hit != 'true'
needs: upload
name: DEB metadata
uses: northwood-labs/package-building/.github/workflows/generate-deb-meta.yml@main
secrets: inherit

metadata_apk:
if: needs.lookup.outputs.cache_hit != 'true'
needs: upload
name: APK metadata
uses: northwood-labs/package-building/.github/workflows/generate-apk-meta.yml@main
secrets: inherit
1 change: 1 addition & 0 deletions installer/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apt-get -y update
apt-get -y install --no-install-recommends \
apt-utils \
ca-certificates \
dialog \
gnupg2 \
lsb-release \
software-properties-common \
Expand Down
49 changes: 49 additions & 0 deletions packages/python3.12/compile-ubuntu-focal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail

export PIP_ROOT_USER_ACTION=ignore

# shellcheck disable=SC2154
git clone https://github.com/python/cpython.git --branch "v${PKG_VER}" --single-branch --depth 1 /tmp/python

cd /tmp/python

# https://devguide.python.org/getting-started/setup-building/
RELEASE=$(lsb_release -cs)
echo "deb-src http://archive.ubuntu.com/ubuntu/ ${RELEASE} main" >>/etc/apt/sources.list
apt-get -y update

apt-get -y build-dep python3-defaults
apt-get -y install --no-install-recommends \
gdb \
lcov \
libbz2-dev \
libffi-dev \
libgdbm-compat-dev \
libgdbm-dev \
liblzma-dev \
libncurses5-dev \
libreadline6-dev \
libsqlite3-dev \
libssl-dev \
lzma \
lzma-dev \
pkg-config \
tk-dev \
uuid-dev \
zlib1g-dev \
;

mkdir -p /tmp/install

./configure \
--disable-test-modules \
--enable-big-digits=30 \
--enable-ipv6 \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--with-lto \
;

# shellcheck disable=SC2046,SC2312
make -j$(nproc) && make install DESTDIR=/tmp/install
49 changes: 49 additions & 0 deletions packages/python3.12/compile-ubuntu-jammy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail

export PIP_ROOT_USER_ACTION=ignore

# shellcheck disable=SC2154
git clone https://github.com/python/cpython.git --branch "v${PKG_VER}" --single-branch --depth 1 /tmp/python

cd /tmp/python

# https://devguide.python.org/getting-started/setup-building/
RELEASE=$(lsb_release -cs)
echo "deb-src http://archive.ubuntu.com/ubuntu/ ${RELEASE} main" >>/etc/apt/sources.list
apt-get -y update

apt-get -y build-dep python3-defaults
apt-get -y install --no-install-recommends \
gdb \
lcov \
libbz2-dev \
libffi-dev \
libgdbm-compat-dev \
libgdbm-dev \
liblzma-dev \
libncurses5-dev \
libreadline6-dev \
libsqlite3-dev \
libssl-dev \
lzma \
lzma-dev \
pkg-config \
tk-dev \
uuid-dev \
zlib1g-dev \
;

mkdir -p /tmp/install

./configure \
--disable-test-modules \
--enable-big-digits=30 \
--enable-ipv6 \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--with-lto \
;

# shellcheck disable=SC2046,SC2312
make -j$(nproc) && make install DESTDIR=/tmp/install
26 changes: 26 additions & 0 deletions packages/python3.12/nfpm-alpine-3.19.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: python3.12
arch: "{{ .Arch }}"
platform: linux
version: ${PKG_VER}
release: 1
section: default
maintainer: Northwood Labs <[email protected]>
description: |-
Python is a clear and powerful object-oriented programming language,
comparable to Perl, Ruby, Scheme, or Java.
vendor: python authors
homepage: https://www.python.org
license: PSF-2.0
disable_globbing: false
provides:
- jenkins-remoting-runner
contents:
- src: /tmp/install/usr
dst: /usr
umask: 0o002
# scripts:
# postinstall: postinstall.sh
apk:
signature:
key_file: signing.pem
key_name: "[email protected]"
28 changes: 28 additions & 0 deletions packages/python3.12/nfpm-amzn-2023.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: python3.12
arch: "{{ .Arch }}"
platform: linux
version: ${PKG_VER}
release: 1
section: default
maintainer: Northwood Labs <[email protected]>
description: |-
Python is a clear and powerful object-oriented programming language,
comparable to Perl, Ruby, Scheme, or Java.
vendor: python authors
homepage: https://www.python.org
license: PSF-2.0
disable_globbing: false
provides:
- jenkins-remoting-runner
contents:
- src: /tmp/install/usr
dst: /usr
umask: 0o002
# scripts:
# postinstall: postinstall.sh
rpm:
summary: "{{ .Var.Description }}"
packager: Northwood Labs <[email protected]>
compression: lzma
signature:
key_file: 3C7658F0.asc
31 changes: 31 additions & 0 deletions packages/python3.12/nfpm-ubuntu-focal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: python3.12
arch: "{{ .Arch }}"
platform: linux
version: ${PKG_VER}
release: 1
section: default
maintainer: Northwood Labs <[email protected]>
description: |-
Python is a clear and powerful object-oriented programming language,
comparable to Perl, Ruby, Scheme, or Java.
vendor: python authors
homepage: https://www.python.org
license: PSF-2.0
disable_globbing: false
provides:
- 2to3-3.12
- idle3.12
- pip3.12
- pydoc3.12
- python3.12
- python3.12-config
contents:
- src: /tmp/install/usr
dst: /usr
umask: 0o002
# scripts:
# postinstall: postinstall.sh
deb:
signature:
key_file: 3C7658F0.asc
type: archive

0 comments on commit 8d945f5

Please sign in to comment.