-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Docker Setup Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Docker Login | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Build and push to Docker Hub | ||
id: hub_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: compilerexplorer/ruby-builder:latest | ||
cache-from: type=registry,ref=compilerexplorer/ruby-builder:latest | ||
cache-to: type=inline | ||
- name: Docker Hub Image Digest | ||
run: echo ${{ steps.hub_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM ubuntu:18.04 | ||
MAINTAINER Matt Godbolt <[email protected]> | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt update -y -q && apt upgrade -y -q && apt update -y -q && \ | ||
apt -q install -y \ | ||
autoconf \ | ||
bison \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
libffi-dev \ | ||
libgdbm-dev \ | ||
libncurses5-dev \ | ||
libreadline6-dev \ | ||
libssl-dev \ | ||
libyaml-dev \ | ||
ruby \ | ||
unzip \ | ||
xz-utils \ | ||
zlib1g-dev \ | ||
&& \ | ||
cd /tmp && \ | ||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ | ||
unzip awscliv2.zip && \ | ||
./aws/install && \ | ||
rm -rf aws* \ | ||
&& \ | ||
# Remove apt's lists to make the image smaller. | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /root | ||
COPY build /root/ | ||
|
||
WORKDIR /root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
ROOT=$PWD | ||
VERSION=$1 | ||
|
||
URL=https://github.com/ruby/ruby.git | ||
|
||
case $VERSION in | ||
trunk) | ||
VERSION=trunk-$(date +%Y%m%d) | ||
BRANCH=master | ||
;; | ||
*) | ||
TAG=v${VERSION//./_} | ||
;; | ||
esac | ||
|
||
# use tag name as branch if otherwise unspecified | ||
BRANCH=${BRANCH-$TAG} | ||
|
||
# some builds checkout a tag instead of a branch | ||
# these builds have a different prefix for ls-remote | ||
REF=refs/heads/${BRANCH} | ||
if [[ ! -z "${TAG}" ]]; then | ||
REF=refs/tags/${TAG} | ||
fi | ||
|
||
# determine build revision | ||
REVISION=$(git ls-remote "${URL}" "${REF}" | cut -f 1) | ||
LAST_REVISION="${3}" | ||
|
||
echo "ce-build-revision:${REVISION}" | ||
|
||
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then | ||
echo "ce-build-status:SKIPPED" | ||
exit | ||
fi | ||
|
||
FULLNAME=ruby-${VERSION} | ||
OUTPUT=${ROOT}/${FULLNAME}.tar.xz | ||
S3OUTPUT= | ||
if [[ $2 =~ ^s3:// ]]; then | ||
S3OUTPUT=$2 | ||
else | ||
if [[ -d "${2}" ]]; then | ||
OUTPUT=$2/${FULLNAME}.tar.xz | ||
else | ||
OUTPUT=${2-$OUTPUT} | ||
fi | ||
fi | ||
|
||
BUILD_DIR=${ROOT}/build | ||
STAGING_DIR=/opt/compiler-explorer/${FULLNAME} | ||
rm -rf "${STAGING_DIR}" | ||
mkdir -p "${STAGING_DIR}" | ||
mkdir -p "${BUILD_DIR}" | ||
|
||
# Setup ruby checkout | ||
git clone --depth 1 --single-branch -b "${BRANCH}" "${URL}" "${ROOT}/ruby" | ||
|
||
# Generate autoconf | ||
cd "${ROOT}/ruby" | ||
if [[ -f "./autogen.sh" ]]; then | ||
./autogen.sh | ||
else | ||
# older ruby doesn't have autogen.sh | ||
autoreconf --install | ||
fi | ||
|
||
# Configure build | ||
cd "${BUILD_DIR}" | ||
../ruby/configure \ | ||
--prefix="${STAGING_DIR}" \ | ||
--disable-install-doc | ||
|
||
# Build and install artifacts | ||
make -j $(nproc) | ||
make install | ||
|
||
# Don't try to compress the binaries as they don't like it | ||
|
||
export XZ_DEFAULTS="-T 0" | ||
tar Jcf ${OUTPUT} --transform "s,^./,./${FULLNAME}/," -C ${STAGING_DIR} . | ||
|
||
if [[ ! -z "${S3OUTPUT}" ]]; then | ||
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}" | ||
fi |