Skip to content

Commit

Permalink
Create a workflow for publishing new ruby versions
Browse files Browse the repository at this point in the history
When new ruby versions are released, we want to publish new versions of the existing images for those ruby versions, rather than cut a new version of the image. So let's create a manually GH workflow that publishes a list of ruby versions for a list of image tags.
  • Loading branch information
andrewn617 committed Apr 23, 2024
1 parent 6fd5cca commit ddaf951
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 70 deletions.
49 changes: 49 additions & 0 deletions .github/actions/build-and-publish-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and Publish Image
description: Steps for building an image for a specific ruby version
inputs:
ruby_version:
required: true
image_tag:
required: true
gh_token:
required: true
repository_owner:
required: true
runs:
using: "composite"
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v3
with:
ref: ${{ inputs.image_tag }}

- name: Set up QEMU for multi-architecture builds
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Set Image version env variable
run: echo "IMAGE_VERSION=$(echo ${{ inputs.image_tag }} | tr -d ruby-)" >> $GITHUB_ENV
shell: bash

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ inputs.repository_owner }}
password: ${{ inputs.gh_token }}

- name: Pre-build Dev Container Image
uses: devcontainers/[email protected]
env:
RUBY_VERSION: ${{ inputs.ruby_version }}
BUILDX_NO_DEFAULT_ATTESTATIONS: true
with:
imageName: ghcr.io/rails/devcontainer/images/ruby
imageTag: ${{ env.IMAGE_VERSION }}-${{ inputs.ruby_version }},${{ inputs.ruby_version }}
subFolder: images/ruby
push: always
platform: linux/amd64,linux/arm64
69 changes: 0 additions & 69 deletions .github/workflows/build-and-publish-images.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/publish-new-image-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Publish Images

on:
push:
tags: [ 'ruby-*.*.*' ]

jobs:
build:
name: Build Images

strategy:
fail-fast: false
matrix:
RUBY_VERSION:
- 3.3.0
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v3

- name: Build and Publish Image
uses: ./.github/actions/build-and-publish-image.yml
with:
ruby_version: ${{ matrix.RUBY_VERSION }}
image_tag: ${{ github.ref_name }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
repository_owner: ${{ github.repository_owner }}
39 changes: 39 additions & 0 deletions .github/workflows/publish-new-ruby-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Publish New Ruby Versions

on:
workflow_dispatch:
inputs:
ruby_versions:
type: string
required: true
description: List of ruby versions to build. Should be an array ["3.3.1","3.2.4"]
image_versions:
type: string
required: true
description: List of image versions to build. Should be an array ["ruby-0.3.0"]

jobs:
build:
name: Build Images

strategy:
fail-fast: false
matrix:
RUBY_VERSION: ${{ fromJSON(github.event.inputs.ruby_versions)}}
IMAGE_VERSION: ${{ fromJSON(github.event.inputs.image_versions)}}

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v3

- name: Build and Publish Image
uses: ./.github/actions/build-and-publish-image.yml
with:
ruby_version: ${{ matrix.RUBY_VERSION }}
image_tag: ${{ matrix.IMAGE_VERSION }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
repository_owner: ${{ github.repository_owner }}
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,16 @@ the same process as for features.

The image is published using the [devcontainers/ci](https://github.com/devcontainers/ci) Github Action. This workflow
is kicked off by the creation of a new tag on Github. Tags should be in the form `ruby-*.*.*`, where the * represent
the **image version** (not the ruby version). Images will be published for all `3.*.*` ruby versions.
the **image version** (not the ruby version). Images will be published for all `3.*.*` ruby versions.

## Publishing new Ruby versions

When a new Ruby version is released, we can build and publish the existing image for the new ruby version, without
needing to cut a new version of the image itself. To do this, we can run the Publish New Ruby Versions workflow
manually. The workflow takes a list of a ruby versions and a list of image tags as inputs. They should be formatted
as comma separated arrays. For example:

```
ruby_versions: ["3.3.1","3.2.4","3.1.5","3.0.7"]
image_versions: ["ruby-0.3.0"]
```

0 comments on commit ddaf951

Please sign in to comment.