Skip to content

Commit

Permalink
Build for multiple GHC versions
Browse files Browse the repository at this point in the history
  • Loading branch information
4TT1L4 committed Jul 23, 2024
1 parent ca0ca5a commit 3ce53a4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build-haskell-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Haskell Image

on:
workflow_call:
inputs:
ghc-version:
description: 'GHC version'
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: docker-metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
build-args: |
GHC=${{ inputs.ghc-version }}
tags: |
# latest tag for the default branch:
type=raw,value=${{ inputs.ghc-version }},enable={{is_default_branch}}
- name: ${{ github.ref == 'refs/heads/main' && 'Build and Push Docker image' || 'Build Docker image' }}
uses: docker/build-push-action@v5
with:
push: ${{ github.ref == 'refs/heads/main'}}
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
38 changes: 9 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,12 @@ on:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: docker-metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
# latest tag for the default branch:
type=raw,value=latest,enable={{is_default_branch}}
- name: ${{ github.ref == 'refs/heads/main' && 'Build and Push Docker image' || 'Build Docker image' }}
uses: docker/build-push-action@v5
with:
push: ${{ github.ref == 'refs/heads/main'}}
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-9-6-5:
uses: ./.github/workflows/build-haskell-image.yml
with:
ghc-version: '9.6.5'

build-9-2-8:
uses: ./.github/workflows/build-haskell-image.yml
with:
ghc-version: '9.2.8'

0 comments on commit 3ce53a4

Please sign in to comment.