File tree Expand file tree Collapse file tree
actions/build-and-publish-image Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 ruby_version :
99 required : true
1010 description : " The version of Ruby to build the image for"
11+ git_version :
12+ required : false
13+ description : " The exact Git version to use instead of latest when building an image"
1114 build_platform :
1215 required : false
1316 description : " The single platform to build (linux/amd64 or linux/arm64)"
4245 with :
4346 ref : ${{ inputs.image_tag }}
4447
48+ - name : Use the resolved Git version
49+ if : ${{ inputs.publish_manifest != 'true' }}
50+ shell : bash
51+ env :
52+ GIT_VERSION : ${{ inputs.git_version }}
53+ run : |
54+ # Update the checked-out config, including for older tags. The Git feature skips its API lookup for exact versions.
55+ ruby -rjson -e '
56+ path, version = ARGV
57+ config = JSON.parse(File.read(path))
58+ git = config.dig("features", "ghcr.io/devcontainers/features/git:1")
59+ exit unless git && git["version"] == "latest"
60+
61+ git["version"] = version
62+ File.write(path, JSON.pretty_generate(config) + "\n")
63+ ' images/ruby/.devcontainer/devcontainer.json "${GIT_VERSION:?}"
64+
4565 - name : Set up Docker Buildx
4666 if : ${{ inputs.publish_manifest != 'true' }}
4767 uses : docker/setup-buildx-action@v4
Original file line number Diff line number Diff line change @@ -24,8 +24,27 @@ defaults:
2424 shell : bash
2525
2626jobs :
27+ resolve-git-version :
28+ name : Resolve Git Version
29+ runs-on : ubuntu-24.04
30+ permissions :
31+ contents : read
32+ outputs :
33+ git_version : ${{ steps.git-version.outputs.git_version }}
34+ steps :
35+ - id : git-version
36+ env :
37+ GH_TOKEN : ${{ secrets.gh_token }}
38+ run : |
39+ git_version=$(gh api repos/git/git/tags --jq '
40+ map(.name | select(test("^v[0-9]+\\.[0-9]+\\.[0-9]+$")) | ltrimstr("v"))
41+ | max_by(split(".") | map(tonumber)) // error("No stable Git tag found")
42+ ')
43+ printf 'git_version=%s\n' "$git_version" >> "$GITHUB_OUTPUT"
44+
2745 build :
2846 name : Build Images
47+ needs : resolve-git-version
2948 strategy :
3049 fail-fast : false
3150 matrix :
5170 uses : ./.github/actions/build-and-publish-image
5271 with :
5372 ruby_version : ${{ matrix.RUBY_VERSION }}
73+ git_version : ${{ needs.resolve-git-version.outputs.git_version }}
5474 build_platform : ${{ matrix.TARGET.BUILD_PLATFORM }}
5575 platform_suffix : ${{ matrix.TARGET.PLATFORM_SUFFIX }}
5676 image_tag : ${{ matrix.IMAGE_VERSION }}
Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ The image is published using the [devcontainers/ci](https://github.com/devcontai
4040is kicked off by the creation of a new tag on Github. Tags should be in the form ` ruby-*.*.* ` , where the * represent
4141the ** image version** (not the ruby version). Images will be published for all [ maintained Ruby versions] ( https://www.ruby-lang.org/en/downloads/ ) .
4242
43+ The workflow uses ` GITHUB_TOKEN ` to find the latest stable Git version before it starts the builds.
44+ Each build uses the same Git version. The workflow does not pass the token to the Docker build.
45+
4346## Publishing new Ruby versions
4447
4548When a new Ruby version is released, we need to add it to the build matrix and potentially update the default version.
You can’t perform that action at this time.
0 commit comments