forked from qemu-bsd-user/qemu-bsd-user
-
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (82 loc) · 2.98 KB
/
bsd-user.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Build, Test & Publush
# Controls when the action will run.
on:
# Triggers the workflow on all push or pull request events
push:
pull_request:
release:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
# added using https://github.com/step-security/secure-repo
permissions:
contents: read
jobs:
build_in_docker:
name: Build&Push to Registry
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
fail-fast: false
matrix:
base_image: ['debian:12-slim', 'ubuntu:latest']
env:
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/qemu-bsd-user-l4b
BASE_IMAGE: ${{ matrix.base_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- 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.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set dynamic environment
run: |
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
OS_TAG="`echo ${{ env.BASE_IMAGE }} | sed 's|:|-|g'`"
# linux/arm/v7 is missing latest clang
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
sort -u | ./bsd-user/scripts/ci/get-arch-buildargs fltplatforms | paste -sd ','`"
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
echo "OS_TAG=${OS_TAG}" >> $GITHUB_ENV
echo "BUILD_IMAGE=${{ env.GHCR_REPO }}:latest-${OS_TAG}" >> $GITHUB_ENV
- name: Build L4B Qemu container image
uses: docker/build-push-action@v6
env:
CACHE_SPEC: "type=registry,ref=${{ env.GHCR_REPO }}:${{ env.GIT_BRANCH }}-${{ env.OS_TAG}}-buildcache"
with:
context: .
file: ./bsd-user/scripts/ci/Dockerfile
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
tags: ${{ env.BUILD_IMAGE }}
platforms: ${{ env.PLATFORMS }}
push: true
cache-from: ${{ env.CACHE_SPEC }}
cache-to: ${{ env.CACHE_SPEC }},mode=max
- name: Register FreeBSD binfmt
run: |
docker run --rm --privileged ${{ env.BUILD_IMAGE }}
- name: Build FreeBSD/base container image
uses: docker/build-push-action@v6
with:
context: ./bsd-user/scripts/ci
file: ./bsd-user/scripts/ci/Dockerfile.FreeBSD_base
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
BUILD_IMAGE=${{ env.BUILD_IMAGE }}
tags: "${{ env.BUILD_IMAGE }}-freebsd141"
platforms: ${{ env.PLATFORMS }}
push: true