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 27090c9
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 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,40 @@ jobs:
jq-*.zip
docker:
needs: linux
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 executables
uses: actions/download-artifact@v3
with:
submodules: true
path: artifacts
- name: Move executables
run: |
mkdir -p linux/{amd64,arm64}
mv artifacts/jq-linux-ubuntu-22.04-gcc-x86_64/jq linux/amd64/jq
mv artifacts/jq-linux-ubuntu-22.04-gcc-aarch64/jq linux/arm64/jq
chmod +x linux/*/jq
- name: Create Dockerfile
run: |
cat <<EOF >Dockerfile
FROM scratch
ARG TARGETPLATFORM
RUN echo "$TARGETPLATFORM ${TARGETPLATFORM}"
COPY AUTHORS COPYING ${TARGETPLATFORM}/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 +281,15 @@ jobs:
context: .
push: true
provenance: false
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm64
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 27090c9

Please sign in to comment.