Adds macos runner to create arm64 build and merges manifest #4
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: Earthly build | |
on: | |
workflow_dispatch: | |
push: | |
branches: ['main'] | |
tags: ['*'] | |
pull_request: | |
schedule: | |
- cron: '0 11 * * *' | |
jobs: | |
build-testing-results: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up earthly | |
run: | | |
sudo wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly | |
sudo chmod 755 /usr/local/bin/earthly | |
- name: Build Space ROS | |
id: build | |
run: | | |
earthly --ci --output +sources | |
earthly --ci --output +build-testing | |
echo "archivename=$(basename log/build_results_archives/build_results_*.tar.bz2)" >> $GITHUB_ENV | |
- name: Upload build results archive | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{env.archivename}} | |
path: log/build_results_archives/${{env.archivename}} | |
if-no-files-found: error | |
space-ros-image: | |
outputs: | |
output_ubuntu: ${{steps.push_image.outputs.output_ubuntu-latest}} | |
output_macos: ${{steps.push_image.outputs.output_macos-14}} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
earthly: earthly-linux-amd64 | |
- os: macos-14 | |
earthly: earthly-darwin-arm64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to ghcr | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install prerequisites | |
if: ${{ startsWith(matrix.os, 'macos') }} | |
run: | | |
brew install --cask docker | |
- name: Set up earthly | |
run: | | |
sudo wget https://github.com/earthly/earthly/releases/latest/download/${{matrix.earthly}} -O /usr/local/bin/earthly | |
sudo chmod 755 /usr/local/bin/earthly | |
- name: Build spaceros image | |
run: | | |
earthly --ci --output +sources | |
earthly --ci +image | |
- name: Push tagged spaceros images to Dockerhub | |
id: push_image | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_RW_TOKEN }} | |
TAG: osrf/space-ros:${{ github.ref_name }}-${{ runner.arch }} | |
if: ${{ github.ref_type == 'tag' }} | |
run: | | |
echo $DOCKER_HUB_TOKEN | docker login --username osrfbot --password-stdin | |
earthly --ci --push +push-image --TAG="$TAG" --LATEST="" | |
echo "output_${{ matrix.os }}=${TAG}" >> "$GITHUB_OUTPUT" | |
- name: Push the main spaceros image to GHCR | |
if: ${{ github.ref_name == 'main' && startsWith(matrix.os, 'ubuntu') }} | |
run: | | |
earthly --ci --push +push-image --TAG="ghcr.io/space-ros/space-ros:main" --LATEST="" | |
combine-manifests: | |
runs-on: ubuntu-latest | |
needs: space-ros-image | |
steps: | |
- name: Combine Manifests | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_RW_TOKEN }} | |
- run: | | |
echo $DOCKER_HUB_TOKEN | docker login --username osrfbot --password-stdin | |
docker manifest create osrf/space-ros \ | |
--amend ${{ join(needs.space-ros-image.outputs, ' --amend ') }} | |
docker manifest push osrf/space-ros:${{ github.ref_name }} |