From 243c070d1f18aee12334c2b2bddc52d941258bbb Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:14:17 +0200 Subject: [PATCH] Add job to publish nightly builds --- .github/workflows/ci.yml | 8 ++--- .github/workflows/nightly.yml | 62 +++++++++++++++++++++++++++++++++++ README.md | 31 +++++------------- nightly-versions.rb | 23 +++++++++++++ variants.rb | 7 ++++ 5 files changed, 105 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/nightly.yml create mode 100755 nightly-versions.rb create mode 100755 variants.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e33b8b..aec135b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..111569b --- /dev/null +++ b/.github/workflows/nightly.yml @@ -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 }} diff --git a/README.md b/README.md index 43c76b2..7bb6b68 100644 --- a/README.md +++ b/README.md @@ -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/) | - - +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 diff --git a/nightly-versions.rb b/nightly-versions.rb new file mode 100755 index 0000000..2d047b2 --- /dev/null +++ b/nightly-versions.rb @@ -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 }) diff --git a/variants.rb b/variants.rb new file mode 100755 index 0000000..a96fa2d --- /dev/null +++ b/variants.rb @@ -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