Skip to content

Commit

Permalink
Merge pull request #71 from ruby/rewrite-multiarch
Browse files Browse the repository at this point in the history
Rewrite multiarch workflow with matrix build
  • Loading branch information
hsbt authored Feb 2, 2024
2 parents e9b0880 + 81b3eac commit 5525d02
Showing 1 changed file with 34 additions and 89 deletions.
123 changes: 34 additions & 89 deletions .github/workflows/build_multiarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ env:

jobs:
build_amd64:
if: "${{ inputs.ruby_version }} && !'nightly' == ${{ inputs.ruby_version }}"
strategy:
matrix:
dev_suffix: [ '', '-dev' ]

runs-on: ubuntu-latest

Expand All @@ -36,7 +38,7 @@ jobs:
push_tags: |
${{ inputs.ruby_version }}-${{ inputs.ubuntu_version }}-amd64-${{ github.sha }}
${{ inputs.ruby_version }}-dev-${{ inputs.ubuntu_version }}-amd64-${{ github.sha }}
dev_suffix: "-dev"
dev_suffix: ${{ matrix.dev_suffix }}
only_development: false
optflags: ''
cppflags: ''
Expand All @@ -45,24 +47,25 @@ jobs:
steps:
- uses: actions/[email protected]

- uses: "./.github/actions/build_image"
if: "!${{ env.only_development }}"
with:
ruby_version: "${{ env.ruby_version }}"
nightly: "${{ env.nightly }}"
image_version_suffix: "${{ env.image_version_suffix }}"
ubuntu_version: "${{ env.ubuntu_version }}"
tag_suffix: "${{ env.tag_suffix }}"
latest_tag: 'true'
- run: |
if [ "${{ env.dev_suffix }}" = "-dev" ]; then
echo "target=development" >> $GITHUB_ENV
echo "latest_tag=false" >> $GITHUB_ENV
else
echo "target=ruby" >> $GITHUB_ENV
echo "latest_tag=true" >> $GITHUB_ENV
fi
- uses: "./.github/actions/build_image"
if: "!${{ env.only_development }}"
with:
ruby_version: "${{ env.ruby_version }}"
nightly: "${{ env.nightly }}"
image_version_suffix: "${{ env.image_version_suffix }}${{ env.dev_suffix }}"
ubuntu_version: "${{ env.ubuntu_version }}"
tag_suffix: "${{ env.tag_suffix }}"
target: development
latest_tag: ${{ env.latest_tag }}
target: ${{ env.target }}

- uses: "./.github/actions/push_image"
if: "${{ env.push }}"
Expand All @@ -79,7 +82,9 @@ jobs:
push_tags: "${{ env.push_tags }}"

build_arm64:
if: "${{ inputs.ruby_version }} && !'nightly' == ${{ inputs.ruby_version }}"
strategy:
matrix:
dev_suffix: [ '', '-dev' ]

runs-on: ubuntu-latest

Expand All @@ -93,7 +98,7 @@ jobs:
push_tags: |
${{ inputs.ruby_version }}-${{ inputs.ubuntu_version }}-arm64-${{ github.sha }}
${{ inputs.ruby_version }}-dev-${{ inputs.ubuntu_version }}-arm64-${{ github.sha }}
dev_suffix: "-dev"
dev_suffix: ${{ matrix.dev_suffix }}
only_development: false
optflags: ''
cppflags: ''
Expand All @@ -102,26 +107,26 @@ jobs:
steps:
- uses: actions/[email protected]

- uses: "./.github/actions/build_image"
if: "!${{ env.only_development }}"
with:
ruby_version: "${{ env.ruby_version }}"
nightly: "${{ env.nightly }}"
image_version_suffix: "${{ env.image_version_suffix }}"
ubuntu_version: "${{ env.ubuntu_version }}"
tag_suffix: "${{ env.tag_suffix }}"
arch: 'linux/arm64'
latest_tag: 'true'
- run: |
if [ "${{ env.dev_suffix }}" = "-dev" ]; then
echo "target=development" >> $GITHUB_ENV
echo "latest_tag=false" >> $GITHUB_ENV
else
echo "target=ruby" >> $GITHUB_ENV
echo "latest_tag=true" >> $GITHUB_ENV
fi
- uses: "./.github/actions/build_image"
if: "!${{ env.only_development }}"
with:
ruby_version: "${{ env.ruby_version }}"
nightly: "${{ env.nightly }}"
image_version_suffix: "${{ env.image_version_suffix }}${{ env.dev_suffix }}"
ubuntu_version: "${{ env.ubuntu_version }}"
tag_suffix: "${{ env.tag_suffix }}"
arch: 'linux/arm64'
target: development
latest_tag: ${{ env.latest_tag }}
target: ${{ env.target }}

- uses: "./.github/actions/push_image"
if: "${{ env.push }}"
Expand All @@ -138,69 +143,9 @@ jobs:
push_tags: "${{ env.push_tags }}"

deploy_multiarch:
if: "${{ inputs.ruby_version }} && !'nightly' == ${{ inputs.ruby_version }}"

runs-on: ubuntu-latest

needs:
- build_amd64
- build_arm64

env:
ruby_version: "${{ inputs.ruby_version }}"
ubuntu_version: "${{ inputs.ubuntu_version }}"
registry_name: rubylang

steps:
- uses: actions/[email protected]

- name: Login to ${{ env.registry_name }}
run: |-
case x"${{ env.registry_name }}" in
xrubylang)
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
;;
xghcr.io/ruby)
echo $GHCR_ACCESS_TOKEN | docker login ghcr.io -u $GHCR_USER --password-stdin
;;
*)
echo "ERROR: Unknown registry_name parameter: $registry_name" >&2
exit 1
;;
esac
- name: Create manifest for ${{ env.registry_name }}
run: |-
rake docker:manifest:create \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
architectures="amd64 arm64" \
manifest_suffix=${{ github.sha }} \
latest_tag=true
rake docker:manifest:create \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
architectures="amd64 arm64" \
image_version_suffix=-dev \
manifest_suffix=${{ github.sha }}
- name: Push manifest to ${{ env.registry_name }}
run: |-
rake docker:manifest:push \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
latest_tag=true
rake docker:manifest:push \
registry_name="${{ env.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ env.ubuntu_version }}" \
image_version_suffix=-dev
deploy_multiarch_ghcr:
if: "${{ inputs.ruby_version }} && !'nightly' == ${{ inputs.ruby_version }}"
strategy:
matrix:
registry_name: [ rubylang, ghcr.io/ruby ]

runs-on: ubuntu-latest

Expand All @@ -211,7 +156,7 @@ jobs:
env:
ruby_version: "${{ inputs.ruby_version }}"
ubuntu_version: "${{ inputs.ubuntu_version }}"
registry_name: ghcr.io/ruby
registry_name: "${{ matrix.registry_name }}"

steps:
- uses: actions/[email protected]
Expand Down

0 comments on commit 5525d02

Please sign in to comment.