Provides available Ruby versions as a JSON output. It runs in one of two modes, chosen automatically by the inputs:
- ruby-lang.org mode (default): latest stable releases from cache.ruby-lang.org, with download URL and sha256 checksum.
- container-registry mode: set
repositoryto list the regular Ruby releases available as tags in that repository.
Migrating from v1: the action now calls a subcommand-based checker binary and passes all inputs by name (no positional args). Pin to @v2.
- name: Fetch Ruby versionsid: ruby-versionsuses: moritzheiber/ruby-versions-action@v2
- name: Display latest versionsrun: echo ${{ steps.ruby-versions.outputs.versions }}To list the Ruby versions available in a container repository, set repository:
- name: Fetch available Ruby image tagsid: ruby-imagesuses: moritzheiber/ruby-versions-action@v2with:
repository: library/rubysuffixes: slim,bookworm
- name: Display available tagsrun: echo ${{ steps.ruby-images.outputs.versions }}# ["3.2.11","3.2.11-slim","3.3.11-bookworm","3.4.10", ...]A more elaborate version builds a matrix for other jobs out of the outputs:
# [...]jobs:
gather-versions:
runs-on: ubuntu-latestoutputs:
versions: ${{ steps.ruby-versions.outputs.versions }}metadata: ${{ steps.ruby-versions.outputs.metadata }}steps:
- uses: moritzheiber/ruby-versions-action@v2with:
version_name: rubychecksum_name: ruby_checksumname: Fetch latest Ruby versionsid: ruby-versionsuse-versions:
runs-on: ubuntu-latestneeds: ["gather-versions"]strategy:
matrix:
ruby: ${{ fromJSON(needs.gather-versions.outputs.versions) }}include: ${{ fromJSON(needs.gather-versions.outputs.metadata) }}steps:
- run: echo "My version is ${{ matrix.ruby }} and my checksum is ${{ matrix.ruby_checksum }}"The include statement adds ruby_checksum to every version in the ruby array. Passing version_name and checksum_name to the gathering step keeps the include keys aligned with the ruby array index. The expanded matrix looks like this:
# [...]ruby: ["3.0.5","3.1.3","3.2.0"]include:
- ruby: "3.0.5"ruby_checksum: "[...]"url: "[...]"
- ruby: "3.1.3"ruby_checksum: "[...]"url: "[...]"
- ruby: "3.2.0"ruby_checksum: "[...]"url: "[...]"Note: the url field isn't used in our example, but you could use it if you wanted to.
Container reference to inspect. Setting it switches to container-registry mode; empty (default) fetches from ruby-lang.org. May include a registry host and an optional trailing tag (ignored):
- id: ruby-imagesuses: moritzheiber/ruby-versions-action@v2with:
repository: ghcr.io/acme/ruby-runtime
- run: echo ${{ steps.ruby-images.outputs.versions }}# ["3.2.11","3.3.11","3.4.10"]Comma-separated tag suffixes to treat as the base version (container-registry mode). Without it only bare major.minor.patch tags are returned; with it, matching suffixed variants are included too:
- id: ruby-imagesuses: moritzheiber/ruby-versions-action@v2with:
repository: library/rubysuffixes: slim,bookworm
- run: echo ${{ steps.ruby-images.outputs.versions }}# ["3.4.10","3.4.10-slim","3.4.10-bookworm"]Registry credentials for container-registry mode. Both must be set; otherwise the registry is queried anonymously. Use secrets:
- id: ruby-imagesuses: moritzheiber/ruby-versions-action@v2with:
repository: ghcr.io/acme/ruby-runtimeusername: ${{ secrets.REGISTRY_USERNAME }}password: ${{ secrets.REGISTRY_PASSWORD }}The name for the version key in the metadata output (ruby-lang.org mode). The default is version:
- id: ruby-versionsuses: moritzheiber/ruby-versions-action@v2with:
version_name: release
- name: Display latest versionsrun: echo ${{ steps.ruby-versions.outputs.versions }}# [{"url":"https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.5.tar.gz","release":"3.0.5","checksum":"9afc6380a027a4fe1ae1a3e2eccb6b497b9c5ac0631c12ca56f9b7beb4848776"}[...]The name for the url key in the metadata output (ruby-lang.org mode). The default is url:
- id: ruby-versionsuses: moritzheiber/ruby-versions-action@v2with:
url_name: download_url
- name: Display latest versionsrun: echo ${{ steps.ruby-versions.outputs.versions }}# [{"version":"3.0.5","download_url":"https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.5.tar.gz","checksum":"9afc6380a027a4fe1ae1a3e2eccb6b497b9c5ac0631c12ca56f9b7beb4848776"}[...]The name for the checksum key in the metadata output (ruby-lang.org mode). The default is checksum:
- id: ruby-versionsuses: moritzheiber/ruby-versions-action@v2with:
checksum_name: sha256sum
- name: Display latest versionsrun: echo ${{ steps.ruby-versions.outputs.versions }}# [{"url":"https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.5.tar.gz","version":"3.0.5","sha256sum":"9afc6380a027a4fe1ae1a3e2eccb6b497b9c5ac0631c12ca56f9b7beb4848776"}[...]The available Ruby versions as a JSON array. In ruby-lang.org mode, the latest stable release versions:
["3.0.5","3.1.3","3.2.0"]In container-registry mode, the matching image tags (including suffixed variants), sorted by version:
["3.2.11","3.2.11-slim","3.3.11","3.3.11-slim","3.4.10","3.4.10-slim"]Only populated in ruby-lang.org mode. Each release with its tar.gz download URL on the Ruby server and sha256 checksum:
[
{
"url": "https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.5.tar.gz",
"version": "3.0.5",
"checksum": "9afc6380a027a4fe1ae1a3e2eccb6b497b9c5ac0631c12ca56f9b7beb4848776"
},
{
"url": "https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.3.tar.gz",
"version": "3.1.3",
"checksum": "5ea498a35f4cd15875200a52dde42b6eb179e1264e17d78732c3a57cd1c6ab9e"
},
{
"url": "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz",
"version": "3.2.0",
"checksum": "daaa78e1360b2783f98deeceb677ad900f3a36c0ffa6e2b6b19090be77abc272"
}
]