Bump actions/upload-artifact from 3 to 4 #135
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: Build-Test-Push | |
on: | |
schedule: | |
- cron: "5 4 * * 3" | |
pull_request: | |
paths-ignore: | |
- "README.md" | |
- "LICENSE.md" | |
push: | |
paths-ignore: | |
- "README.md" | |
- "LICENSE.md" | |
jobs: | |
gather-versions: | |
runs-on: ubuntu-24.04 | |
outputs: | |
versions: ${{ steps.ruby-versions.outputs.versions }} | |
metadata: ${{ steps.ruby-versions.outputs.metadata }} | |
steps: | |
- uses: moritzheiber/ruby-versions-action@v1 | |
name: Fetch latest Ruby versions | |
id: ruby-versions | |
build-test-push: | |
needs: ["gather-versions"] | |
strategy: | |
matrix: | |
version: ${{ fromJSON(needs.gather-versions.outputs.versions) }} | |
image: [slim, ubuntu-22.04, ubuntu-24.04] | |
platform: [amd64, arm64] | |
include: ${{ fromJSON(needs.gather-versions.outputs.metadata) }} | |
runs-on: ${{ matrix.platform == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} | |
steps: | |
- name: Set image_name | |
id: context | |
run: | | |
if [[ "${{ matrix.image }}" == "slim" ]] ; then | |
echo "image_name=ruby:${{ matrix.version }}-slim" >> ${GITHUB_OUTPUT} | |
elif [[ "${{ matrix.image }}" == "ubuntu-22.04" ]] ; then | |
echo "image_name=ubuntu:22.04" >> ${GITHUB_OUTPUT} | |
elif [[ "${{ matrix.image }}" == "ubuntu-24.04" ]] ; then | |
echo "image_name=ubuntu:24.04" >> ${GITHUB_OUTPUT} | |
fi | |
if [[ "${{ startsWith(matrix.version, '3.2') }}" == "true" ]] ; then | |
echo "flags=--enable-yjit" >> ${GITHUB_OUTPUT} | |
fi | |
- uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: | | |
image=moby/buildkit:v0.19.0 | |
- uses: docker/build-push-action@v6 | |
name: Build | |
id: build | |
with: | |
platforms: linux/${{ matrix.platform }} | |
push: ${{ github.ref == 'refs/heads/main' }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
RUBY_VERSION=${{ matrix.version }} | |
RUBY_CHECKSUM=${{ matrix.checksum }} | |
IMAGE_NAME=${{ steps.context.outputs.image_name }} | |
ADDITIONAL_FLAGS=${{ steps.context.outputs.flags }} | |
provenance: false | |
outputs: | | |
type=image,name=ghcr.io/moritzheiber/ruby-jemalloc,push-by-digest=true,push=${{ github.ref == 'refs/heads/main' }} | |
- name: Export digest | |
if: github.ref == 'refs/heads/main' | |
run: | | |
mkdir -p /tmp/digests/${{ matrix.version }}-${{ matrix.image }} | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${{ matrix.version }}-${{ matrix.image }}/${digest#sha256:}" | |
- name: Upload digest | |
if: github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ matrix.version }}-${{ matrix.image }} | |
path: /tmp/digests/${{ matrix.version }}-${{ matrix.image }}/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge-manifests: | |
needs: ["build-test-push", "gather-versions"] | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
version: ${{ fromJSON(needs.gather-versions.outputs.versions) }} | |
image: [slim, ubuntu-22.04, ubuntu-24.04] | |
steps: | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: | | |
image=moby/buildkit:v0.19.0 | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests-${{ matrix.version }}-${{ matrix.image }} | |
path: /tmp/digests/${{ matrix.version }}-${{ matrix.image }} | |
- name: Create and push manifest | |
working-directory: /tmp/digests/${{ matrix.version }}-${{ matrix.image }} | |
run: | | |
docker buildx imagetools create -t ghcr.io/moritzheiber/ruby-jemalloc:${{ matrix.version }}-${{ matrix.image }} \ | |
$(printf 'ghcr.io/moritzheiber/ruby-jemalloc@sha256:%s ' *) |