Skip to content

Commit

Permalink
Build Docker image using pre-built executables
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Jul 8, 2023
1 parent a72cffe commit 842d952
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- improve-docker-image-build
tags:
- "jq-*"
pull_request:
Expand Down Expand Up @@ -230,21 +231,41 @@ jobs:
jq-*.zip
docker:
needs: linux
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
include:
- platform: linux/amd64
suffix: linux-ubuntu-22.04-gcc-x86_64
- platform: linux/arm64
suffix: linux-ubuntu-22.04-gcc-aarch64
runs-on: ubuntu-latest
permissions:
packages: write
if: startsWith(github.ref, 'refs/tags/jq-')
# if: startsWith(github.ref, 'refs/tags/jq-')
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Download executable
uses: actions/download-artifact@v3
with:
submodules: true
name: jq-${{ matrix.suffix }}
- name: Create Dockerfile
run: |
chmod +x jq
cat <<EOF >Dockerfile
FROM scratch
COPY AUTHORS COPYING jq /
RUN ["/jq", "--version"]
ENTRYPOINT ["/jq"]
EOF
- name: Docker metadata
uses: docker/metadata-action@v4
id: metadata
with:
images: ghcr.io/${{ github.repository }}
tags: type=match,pattern=jq-(.*),group=1,value=${{ github.ref_name }}
tags: latest # type=match,pattern=jq-(.*),group=1,value=${{ github.ref_name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -261,15 +282,15 @@ jobs:
context: .
push: true
provenance: false
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
platforms: ${{ matrix.platform }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

release:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [linux, macos, windows, dist]
needs: [linux, macos, windows, dist, docker]
if: startsWith(github.ref, 'refs/tags/jq-')
steps:
- name: Clone repository
Expand Down

0 comments on commit 842d952

Please sign in to comment.