Skip to content

Commit

Permalink
Add job to publish nightly builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Jul 2, 2024
1 parent c069afc commit 243c070
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: GitHub CI

on:
pull_request:
push:
# pull_request:
# push:
workflow_dispatch:
schedule:
- cron: 0 0 * * 0
# schedule:
# - cron: 0 0 * * 0

defaults:
run:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker Build

on:
workflow_dispatch:
schedule:
- cron: 0 20 * * *

permissions:
contents: read
packages: write

jobs:
set-up-matrix:
name: Set up matrix
runs-on: ubuntu-latest
outputs:
variants: ${{ steps.fetch-variants.outputs.variants }}
json: ${{ steps.fetch-json.outputs.json }}
steps:
- uses: actions/checkout@v4
- id: fetch-variants
run: echo "variants=$(./variants.rb)" >> "$GITHUB_OUTPUT"
- id: fetch-json
run: echo "json=$(./nightly-versions.rb)" >> "$GITHUB_OUTPUT"

build:
needs: set-up-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
variant: ${{ fromJson(needs.set-up-matrix.outputs.variants) }}
name: ${{ matrix.variant }}
steps:
- uses: actions/checkout@v4
- run: echo '${{ needs.set-up-matrix.outputs.json }}' > versions.json
- run: echo date=$(jq -r .master.date versions.json) >> $GITHUB_ENV
- run: ./apply-templates.sh

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Build and push
uses: docker/build-push-action@v5
env:
tag1: ghcr.io/docker-ruby-nightly/ruby:${{ matrix.variant }}-nightly-${{ env.date }}
tag2: ghcr.io/docker-ruby-nightly/ruby:${{ matrix.variant }}-nightly
with:
context: ./master/${{ matrix.variant }}
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x
tags: ${{ env.tag1 }},${{ env.tag2 }}
31 changes: 9 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
# https://github.com/docker-library/ruby
![Last successful build](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.github.com%2Frepos%2Fdocker-ruby-nightly%2Fruby%2Factions%2Fworkflows%2Fnightly.yml%2Fruns%3Fstatus%3Dcompleted%26event%3Dschedule&query=%24.workflow_runs%5B0%5D%5B'updated_at'%5D&logo=githubactions&label=Last%20successful%20build) ![Last build status](https://github.com/docker-ruby-nightly/ruby/actions/workflows/nightly.yml/badge.svg)

## Maintained by: [the Docker Community](https://github.com/docker-library/ruby)
Fork of https://github.com/docker-library/ruby to build daily nightly images. Unfortunatly there will be no official nightly builds [[1]](https://github.com/docker-library/ruby/issues/222) and [circleci-ruby-snapshot-image](https://github.com/rubocop/circleci-ruby-snapshot-image) builds have stopped [[2]](https://github.com/rubocop/circleci-ruby-snapshot-image/issues/21).

This is the Git repo of the [Docker "Official Image"](https://github.com/docker-library/official-images#what-are-official-images) for [`ruby`](https://hub.docker.com/_/ruby/) (not to be confused with any official `ruby` image provided by `ruby` upstream). See [the Docker Hub page](https://hub.docker.com/_/ruby/) for the full readme on how to use this Docker image and for information regarding contributing and issues.
The available variants will mirror the ones from the official images. The tags are structured in the following way:
* `alpine3.20-nightly-2024-05-27`
* `alpine3.20-nightly`
* `bookworm-nightly-2024-05-27`
* `bookworm-nightly`

The [full image description on Docker Hub](https://hub.docker.com/_/ruby/) is generated/maintained over in [the docker-library/docs repository](https://github.com/docker-library/docs), specifically in [the `ruby` directory](https://github.com/docker-library/docs/tree/master/ruby).
Images are build for the following architectures: `linux/amd64`, `linux/arm64`, `linux/arm/v7`, `linux/arm/v6`, `linux/386`, `linux/ppc64le`, and `linux/s390x`.

## See a change merged here that doesn't show up on Docker Hub yet?

For more information about the full official images change lifecycle, see [the "An image's source changed in Git, now what?" FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what).

For outstanding `ruby` image PRs, check [PRs with the "library/ruby" label on the official-images repository](https://github.com/docker-library/official-images/labels/library%2Fruby). For the current "source of truth" for [`ruby`](https://hub.docker.com/_/ruby/), see [the `library/ruby` file in the official-images repository](https://github.com/docker-library/official-images/blob/master/library/ruby).

---

- [![build status badge](https://img.shields.io/github/actions/workflow/status/docker-library/ruby/ci.yml?branch=master&label=GitHub%20CI)](https://github.com/docker-library/ruby/actions?query=workflow%3A%22GitHub+CI%22+branch%3Amaster)
- [![build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/update.sh/job/ruby.svg?label=Automated%20update.sh)](https://doi-janky.infosiftr.net/job/update.sh/job/ruby/)

| Build | Status | Badges | (per-arch) |
|:-:|:-:|:-:|:-:|
| [![amd64 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/amd64/job/ruby.svg?label=amd64)](https://doi-janky.infosiftr.net/job/multiarch/job/amd64/job/ruby/) | [![arm32v5 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v5/job/ruby.svg?label=arm32v5)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v5/job/ruby/) | [![arm32v6 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v6/job/ruby.svg?label=arm32v6)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v6/job/ruby/) | [![arm32v7 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v7/job/ruby.svg?label=arm32v7)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v7/job/ruby/) |
| [![arm64v8 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm64v8/job/ruby.svg?label=arm64v8)](https://doi-janky.infosiftr.net/job/multiarch/job/arm64v8/job/ruby/) | [![i386 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/i386/job/ruby.svg?label=i386)](https://doi-janky.infosiftr.net/job/multiarch/job/i386/job/ruby/) | [![mips64le build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/mips64le/job/ruby.svg?label=mips64le)](https://doi-janky.infosiftr.net/job/multiarch/job/mips64le/job/ruby/) | [![ppc64le build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/ppc64le/job/ruby.svg?label=ppc64le)](https://doi-janky.infosiftr.net/job/multiarch/job/ppc64le/job/ruby/) |
| [![s390x build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/s390x/job/ruby.svg?label=s390x)](https://doi-janky.infosiftr.net/job/multiarch/job/s390x/job/ruby/) | [![put-shared build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/put-shared/job/light/job/ruby.svg?label=put-shared)](https://doi-janky.infosiftr.net/job/put-shared/job/light/job/ruby/) |

<!-- THIS FILE IS GENERATED BY https://github.com/docker-library/docs/blob/master/generate-repo-stub-readme.sh -->
The full qualifier looks like `ghcr.io/docker-ruby-nightly/ruby:alpine3.20-nightly-2024-05-27`. List of previous builds: https://github.com/docker-ruby-nightly/ruby/pkgs/container/ruby
23 changes: 23 additions & 0 deletions nightly-versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby

require "json"
require "net/http"

current_json = JSON.parse(File.read("versions.json"))
latest_release = current_json.compact.keys.max_by(&:to_f)
donor = current_json[latest_release]

uri = URI("https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-master.json")
res = Net::HTTP.get_response(uri)
raise StandardError, "Got status code #{res.code}: #{res.body}" unless res.code == "200"

master = JSON.parse(res.body).first
master["url"] = master["filename"].transform_values { |file| "https://cache.ruby-lang.org/pub/ruby/snapshot/#{file}" }
master.delete("filename")
master.merge!({
"version" => "master",
"variants" => donor["variants"],
"rust" => donor["rust"],
"rustup" => donor["rustup"],
})
puts JSON.generate({ "master" => master })
7 changes: 7 additions & 0 deletions variants.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby

require "json"

json = JSON.parse(File.read("versions.json"))
latest_release = json.compact.keys.max_by(&:to_f)
puts json[latest_release]["variants"].to_json

0 comments on commit 243c070

Please sign in to comment.