-
Notifications
You must be signed in to change notification settings - Fork 117
183 lines (164 loc) · 6.82 KB
/
Copy pathrelease.yaml
File metadata and controls
183 lines (164 loc) · 6.82 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: build and release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]*'
workflow_dispatch:
inputs:
tag_ref:
description: 'Tag reference (e.g., v1.2.3)'
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.event.after || github.run_id }}
cancel-in-progress: true
env:
# https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0
LLVM_URL_PREFIX: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0
LLVM_arm64: clang+llvm-15.0.0-aarch64-linux-gnu
LLVM_amd64: clang+llvm-15.0.0-x86_64-linux-gnu-rhel-8.4
# Set the tag reference based on trigger type
TAG_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_ref || github.ref_name }}
jobs:
validate-tag:
name: Validate tag exists (manual dispatch only)
runs-on: ubuntu-22.04
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # Fetch all tags
- name: Check if tag exists
run: |
if ! git tag -l | grep -q "^${{ inputs.tag_ref }}$"; then
echo "Error: Tag '${{ inputs.tag_ref }}' does not exist in the repository"
echo "Available tags:"
git tag -l
exit 1
fi
echo "Tag '${{ inputs.tag_ref }}' found"
build:
name: Build static bpftool binary
runs-on: ubuntu-22.04
needs: [validate-tag]
if: always() && (needs.validate-tag.result == 'success' || needs.validate-tag.result == 'skipped')
env:
TARGETARCH: ${{ matrix.arch }}
FILE_STRING_ARCH_amd64: x86-64
FILE_STRING_ARCH_arm64: aarch64
strategy:
matrix:
arch: [arm64, amd64]
steps:
# amd64 needs the dependencies to build bpftool
- name: Install dependencies (amd64)
if: matrix.arch == 'amd64'
run: |
sudo apt-get update
sudo apt-get install -y libelf-dev libcap-dev libssl-dev
- name: Download and extract compiled LLVM release
env:
LLVM: ${{ env[format('LLVM_{0}', matrix.arch)] }}
run: |
curl -L -O "${{ env.LLVM_URL_PREFIX}}/${{ env.LLVM }}.tar.xz"
tar -xvf "${{ env.LLVM }}.tar.xz"
- name: Checkout bpftool code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
# Create a new directory to avoid wiping out LLVM on bpftool checkout
path: 'bpftool'
# For manual dispatch, checkout the specific tag
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_ref || github.ref }}
- name: Build static bpftool natively for amd64
if: matrix.arch == 'amd64'
working-directory: 'bpftool'
env:
LLVM_PATH: ${{ env[format('LLVM_{0}', matrix.arch)] }}
run: |
EXTRA_LDFLAGS=-static \
LLVM_CONFIG="${GITHUB_WORKSPACE}/${{ env.LLVM_PATH }}/bin/llvm-config" \
LLVM_STRIP="${GITHUB_WORKSPACE}/${{ env.LLVM_PATH }}/bin/llvm-strip" \
HOSTAR="${GITHUB_WORKSPACE}/${{ env.LLVM_PATH }}/bin/llvm-ar" \
make -j -C src V=1
strip src/bpftool
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
if: matrix.arch == 'arm64'
with:
platforms: arm64
# The emulated build leverages Docker and Ubuntu 22.04 container image
# distribution to have all the needed arm64 packages.
- name: Build static bpftool for arm64 with emulation
if: matrix.arch == 'arm64'
env:
LLVM_PATH: ${{ env[format('LLVM_{0}', matrix.arch)] }}
run: |
docker run --platform linux/arm64 --rm -v $(pwd):/build ubuntu:22.04 \
bash -c "apt-get update && \
apt-get install -y make pkg-config gcc libssl-dev \
libelf-dev libcap-dev libstdc++-11-dev zlib1g-dev && \
cd /build/bpftool && \
EXTRA_LDFLAGS=-static \
LLVM_CONFIG='/build/${{ env.LLVM_PATH }}/bin/llvm-config' \
LLVM_STRIP='/build/${{ env.LLVM_PATH }}/bin/llvm-strip' \
CLANG='/build/${{ env.LLVM_PATH }}/bin/clang' \
make -j -C src V=1 && \
strip src/bpftool"
- name: Test bpftool binary
working-directory: 'bpftool/src'
env:
ARCH: ${{ env[format('FILE_STRING_ARCH_{0}', matrix.arch)] }}
run: |
file ./bpftool | \
tee /dev/stderr | \
grep -q "${{ env.ARCH }}"
./bpftool 2>&1 | grep -q Usage
./bpftool -p version | \
tee /dev/stderr | \
jq --exit-status ".features | .llvm and .skeletons"
ldd ./bpftool 2>&1 | \
tee /dev/stderr | \
grep -q 'not a dynamic executable'
- name: Upload Artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ format('bpftool_{0}', matrix.arch) }}
path: bpftool/src/bpftool
draft-release:
name: Create a draft release
runs-on: ubuntu-22.04
needs: [build]
permissions:
contents: write
steps:
- name: Download artifacts from build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- name: Rename binaries and compress
run: |
archive_amd64="bpftool-${{ env.TAG_REF }}-amd64.tar.gz"
archive_arm64="bpftool-${{ env.TAG_REF }}-arm64.tar.gz"
tar -C bpftool_amd64 -I 'gzip -9' -cvf "${archive_amd64}" bpftool
tar -C bpftool_arm64 -I 'gzip -9' -cvf "${archive_arm64}" bpftool
sha256sum "${archive_amd64}" > "${archive_amd64}.sha256sum"
sha256sum "${archive_arm64}" > "${archive_arm64}.sha256sum"
- name: Checkout bpftool and libbpf code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
path: 'bpftool'
# For manual dispatch, checkout the specific tag
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_ref || github.ref }}
- name: Package source code including submodules
uses: qmonnet/git-archive-all-action@791fb850881cf58b1d1fcc9b06c01940080bba0a # v1.0.1
with:
output-files: bpftool-libbpf-${{ env.TAG_REF }}-sources.tar.gz
base-repo: bpftool
- name: Create draft release and add artifacts
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
draft: true
files: bpftool*
tag_name: ${{ env.TAG_REF }}
generate_release_notes: true