Build Linux and macOS binaries in parallel and upload them #1550
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: Docker Build | |
on: | |
push: | |
branches: | |
- main | |
workflow_call: | |
inputs: | |
sha: | |
description: 'Git commit SHA' | |
required: true | |
type: string | |
tag: | |
description: 'Docker tag' | |
required: true | |
type: string | |
default: 'latest' | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
if: github.event_name != 'push' && inputs.tag != 'latest' | |
with: | |
ref: ${{ inputs.sha }} | |
- uses: actions/checkout@v4 | |
if: github.event_name == 'push' | |
- name: Set Docker tag | |
if: github.event_name != 'push' && inputs.tag != 'latest' | |
run: echo "DOCKER_TAG=${{ inputs.tag }}" >> $GITHUB_ENV | |
- name: Use default Docker tag | |
if: github.event_name == 'push' | |
run: echo "DOCKER_TAG=latest" >> $GITHUB_ENV | |
- name: Set lowercase repository name | |
run: echo "REPOSITORY_LC=${REPOSITORY,,}" >> $GITHUB_ENV | |
env: | |
REPOSITORY: '${{ github.repository }}' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
registry: ghcr.io | |
- uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{ env.DOCKER_TAG }} | |
platforms: linux/amd64 | |
outputs: type=local,dest=artifacts | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: swiftlint_linux_amd64 | |
path: artifacts/linux_amd64/workspace/swiftlint | |
retention-days: 2 |