mirror of
https://github.com/nine-lives-later/zzmq.git
synced 2024-09-29 04:48:46 +08:00
Add GitHub workflow for building the examples
This commit is contained in:
parent
305b54d994
commit
4c2ae069c4
54
.github/workflows/examples.yml
vendored
Normal file
54
.github/workflows/examples.yml
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
name: Build Examples
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "zig-*" ]
|
||||
tags: [ 'v*.*.*' ]
|
||||
|
||||
pull_request:
|
||||
branches: [ "main", "zig-*" ]
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}_examples
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# This is used to complete the identity challenge
|
||||
# with sigstore/fulcio when running outside of PRs.
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Set up BuildKit Docker container builder to be able to build
|
||||
# multi-platform images and export cache
|
||||
# https://github.com/docker/setup-buildx-action
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3 # v3.0.0
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5 # v5.0.0
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v5 # v5.0.0
|
||||
with:
|
||||
context: .
|
||||
file: examples.Dockerfile
|
||||
push: false
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
15
build_all_examples.sh
Executable file
15
build_all_examples.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
for x in ./examples/*/build.zig; do
|
||||
EXAMPLEDIR=$(dirname "$x")
|
||||
|
||||
echo "Building example: $EXAMPLEDIR ..."
|
||||
|
||||
pushd $EXAMPLEDIR > /dev/null
|
||||
|
||||
zig build
|
||||
|
||||
popd > /dev/null
|
||||
done
|
7
build_all_examples_docker.sh
Executable file
7
build_all_examples_docker.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
IMAGE=zzmq_examples_347563478
|
||||
|
||||
DOCKER_BUILDKIT=1 docker build . -t $IMAGE -f examples.Dockerfile
|
21
examples.Dockerfile
Normal file
21
examples.Dockerfile
Normal file
|
@ -0,0 +1,21 @@
|
|||
FROM alpine:3.19 as builder
|
||||
|
||||
# install Zig 0.12 from Alpine edge community repo: https://pkgs.alpinelinux.org/package/edge/community/x86_64/zig
|
||||
RUN echo "@edge-community https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
|
||||
RUN apk add --no-cache zig@edge-community~=0.12.0
|
||||
|
||||
# install dependencies
|
||||
RUN apk add --no-cache zeromq-dev clang bash
|
||||
|
||||
COPY . /build/
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN ./build_all_examples.sh
|
||||
|
||||
RUN touch /var/touched # dummy build output
|
||||
|
||||
# empty result image
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /var/touched /tmp/touched
|
Loading…
Reference in New Issue
Block a user