syncthingtray: update to 1.6.3.
[void-pkg.git] / .github / workflows / container.yaml
blob957b6e849d59180acdda37074d6543c410fad0f5
1 ---
2 name: 'Build buildroot containers'
4 on:
5   workflow_dispatch:
6   pull_request:
7     branches:
8       - master
9     paths:
10       - common/container/**
11   push:
12     branches:
13       - master
14     paths:
15       - common/container/**
17 concurrency:
18   group: ${{ github.workflow }}-${{ github.ref }}
19   cancel-in-progress: true
21 jobs:
22   build:
23     runs-on: ubuntu-latest
25     permissions:
26       contents: read
27       packages: write
29     strategy:
30       matrix:
31         libc:
32           - glibc
33           - musl
35     steps:
36       - name: Checkout
37         uses: classabbyamp/treeless-checkout-action@v1
39       - name: Get image release
40         id: release
41         run: |
42           # gets the list of all date-shaped tags for the image, finds the most recent one
43           tag="$(skopeo list-tags "docker://ghcr.io/${{ github.repository_owner }}/void-buildroot-${{ matrix.libc }}" | \
44             jq -r '.Tags | sort | reverse | map(select(test("^[0-9]{8}(R[0-9]+)?$")))[0]')"
45           # tags from a different day or pre-YYYYMMDDRN
46           if [ "${tag%R*}" != "$(date -u +%Y%m%d)" ] || [ "${tag%R*}" = "${tag}" ]; then
47             rel=1
48           else
49             rel=$(( ${tag##*R} + 1 ))
50           fi
51           echo "rel=${rel}" >> "${GITHUB_OUTPUT}"
53       - name: Docker metadata
54         id: meta
55         uses: docker/metadata-action@v4
56         with:
57           images: |
58             ghcr.io/${{ github.repository_owner }}/void-buildroot-${{ matrix.libc }}
59           tags: |
60             type=sha,prefix=
61             type=raw,value=latest,enable={{is_default_branch}}
62             type=raw,value={{date 'YYYYMMDD'}}R${{ steps.release.outputs.rel }},enable={{is_default_branch}},priority=1000
63           flavor: latest=false
64           labels: |
65             org.opencontainers.image.authors=Void Linux team and contributors
66             org.opencontainers.image.url=https://voidlinux.org
67             org.opencontainers.image.documentation=https://github.com/${{ github.repository }}
68             org.opencontainers.image.source=https://github.com/${{ github.repository }}
69             org.opencontainers.image.vendor=Void Linux
70             org.opencontainers.image.title=Void Linux build root
71             org.opencontainers.image.description=Image for building packages with xbps-src on Void Linux
73       - name: Set up QEMU
74         uses: docker/setup-qemu-action@v2
76       - name: Set up Docker Buildx
77         uses: docker/setup-buildx-action@v2
79       - name: Login to GCHR
80         if: github.event_name != 'pull_request'
81         uses: docker/login-action@v2
82         with:
83           registry: ghcr.io
84           username: ${{ github.actor }}
85           password: ${{ secrets.GITHUB_TOKEN }}
87       - name: Build and push images
88         id: build_and_push
89         uses: docker/bake-action@v3
90         with:
91           push: ${{ github.event_name != 'pull_request' }}
92           targets: void-buildroot-${{ matrix.libc }}
93           files: |
94             common/container/docker-bake.hcl
95             ${{ steps.meta.outputs.bake-file }}
96           set: |
97             _common.cache-to=type=gha
98             _common.cache-from=type=gha