Skip to content

Commit 0297094

Browse files
authored
Merge pull request #1 from parca-dev/builds
.github: Automate building artifacts
2 parents 9dba2bf + 7959652 commit 0297094

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

.github/workflows/container.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Container Image Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-and-push:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to Container Registry
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata (tags, labels)
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
# For releases: use semantic version tags
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
type=semver,pattern={{major}}
49+
# For main branch: use date and commit SHA
50+
type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}}
51+
# Also tag as latest for main branch
52+
type=raw,value=latest,enable={{is_default_branch}}
53+
54+
- name: Build and push multi-arch image
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
file: ./Dockerfile
59+
platforms: linux/amd64,linux/arm64
60+
target: runtime
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+
67+
extract-release-binaries:
68+
# Only run this job for tagged releases
69+
if: startsWith(github.ref, 'refs/tags/v')
70+
needs: build-and-push
71+
runs-on: ubuntu-latest
72+
permissions:
73+
contents: write
74+
75+
strategy:
76+
matrix:
77+
platform:
78+
- arch: amd64
79+
platform: linux/amd64
80+
- arch: arm64
81+
platform: linux/arm64
82+
83+
steps:
84+
- name: Checkout repository
85+
uses: actions/checkout@v4
86+
87+
- name: Set up Docker Buildx
88+
uses: docker/setup-buildx-action@v3
89+
90+
- name: Build and extract binary for ${{ matrix.platform.arch }}
91+
run: |
92+
mkdir -p build/${{ matrix.platform.arch }}
93+
docker buildx build -f Dockerfile \
94+
--target export \
95+
--output type=local,dest=build/${{ matrix.platform.arch }} \
96+
--platform ${{ matrix.platform.platform }} \
97+
.
98+
99+
- name: Rename binary with arch suffix
100+
run: |
101+
mv build/${{ matrix.platform.arch }}/libparcagpucupti.so \
102+
build/${{ matrix.platform.arch }}/libparcagpucupti-${{ matrix.platform.arch }}.so
103+
104+
- name: Upload binary as artifact
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: libparcagpucupti-${{ matrix.platform.arch }}
108+
path: build/${{ matrix.platform.arch }}/libparcagpucupti-${{ matrix.platform.arch }}.so
109+
110+
- name: Upload to GitHub Release
111+
uses: softprops/action-gh-release@v1
112+
with:
113+
files: build/${{ matrix.platform.arch }}/libparcagpucupti-${{ matrix.platform.arch }}.so

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \
1212

1313
# Copy source code
1414
WORKDIR /build/cupti
15-
COPY . .
15+
COPY cupti/ .
1616

1717
# Build the library
1818
ENV CUDA_ROOT=/usr/local/cuda

0 commit comments

Comments
 (0)