Release docker images to GHCR #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release docker images to GHCR | |
concurrency: | |
group: "${{github.workflow}}-${{github.ref}}" | |
cancel-in-progress: true | |
# | |
# This workflow assumes the maintainer has chosen the appropriate tag in the workflow dispatch UI. | |
# | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Tag name to release" | |
required: true | |
jobs: | |
build: | |
name: "build ${{ inputs.tag }} ${{ matrix.platform }}" | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- aarch64-linux-gnu | |
- aarch64-linux-musl | |
- arm-linux-gnu | |
- arm-linux-musl | |
- arm64-darwin | |
- jruby | |
- x64-mingw-ucrt | |
- x64-mingw32 | |
- x86-linux-gnu | |
- x86-linux-musl | |
- x86-mingw32 | |
- x86_64-darwin | |
- x86_64-linux-gnu | |
- x86_64-linux-musl | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.tag }} | |
- name: Use cache from primary pipeline | |
uses: actions/cache@v4 | |
with: | |
path: tmp/build-cache | |
key: ${{runner.os}}-${{matrix.platform}}-buildx-${{github.sha}} | |
restore-keys: | | |
${{runner.os}}-${{matrix.platform}}-buildx | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.3" | |
bundler-cache: true | |
- name: Generate docker image names | |
id: rcd_config | |
run: | | |
bundle exec ruby -e ' \ | |
require "rake_compiler_dock"; \ | |
print "image_name="; \ | |
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \ | |
if %q(${{matrix.platform}}).end_with?("-gnu"); \ | |
print "generic_linux_image_name="; \ | |
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})).chomp("-gnu"); \ | |
end \ | |
' | tee -a $GITHUB_OUTPUT | |
- name: Build docker image | |
env: | |
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new --load | |
run: | | |
docker buildx create --driver docker-container --use | |
bundle exec rake build:${{matrix.platform}} | |
# move build cache and remove outdated layers | |
rm -rf tmp/build-cache | |
mv tmp/build-cache-new tmp/build-cache | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Push the docker image | |
run: | | |
docker images | |
docker push ${{steps.rcd_config.outputs.image_name}} | |
- name: Push a generic linux image | |
if: ${{ steps.rcd_config.outputs.generic_linux_image_name }} | |
run: | | |
docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.generic_linux_image_name}} | |
docker push ${{steps.rcd_config.outputs.generic_linux_image_name}} |