-
Notifications
You must be signed in to change notification settings - Fork 50
129 lines (113 loc) · 3.73 KB
/
Copy pathci.yml
File metadata and controls
129 lines (113 loc) · 3.73 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: CI
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
name: Build (CMake) on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
max-size: 250M
- name: Configure (CMake)
run: cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local
- name: Build
run: cmake --build build -j"$(nproc)"
- name: Install
run: cmake --install build
docker:
name: Build and push Docker image to GHCR
# Always build image; push and attest only on default branch or tags
needs: build
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
attestations: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Determine if we should push
id: should_push
run: |
should_push="${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) }}"
if [ "$should_push" = "true" ]; then
echo "push=true" >> "$GITHUB_OUTPUT"
else
echo "push=false" >> "$GITHUB_OUTPUT"
fi
- name: Compute platforms
id: platforms
run: |
if [ "${{ steps.should_push.outputs.push }}" = "true" ]; then
echo "value=${{ env.PLATFORMS }}" >> "$GITHUB_OUTPUT"
else
echo "value=linux/amd64" >> "$GITHUB_OUTPUT"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ steps.platforms.outputs.value }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ steps.platforms.outputs.value }}
- name: Log in to the Container registry
if: ${{ steps.should_push.outputs.push == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build Docker image (push on default branch or tags)
id: push
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ steps.buildx.outputs.platforms }}
push: ${{ steps.should_push.outputs.push == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
load: ${{ steps.should_push.outputs.push != 'true' }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate artifact attestation
if: ${{ steps.should_push.outputs.push == 'true' }}
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true