-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdev-cross-platform-release-s3.yml
More file actions
253 lines (215 loc) · 9.37 KB
/
Copy pathdev-cross-platform-release-s3.yml
File metadata and controls
253 lines (215 loc) · 9.37 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: Development release for client & installer to s3
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- "main"
push:
branches:
- "main"
jobs:
build-and-release:
permissions: write-all
strategy:
matrix:
arch: [x86_64, aarch64, macos-arm64, macos-x86_64]
channel: [dev, prod]
include:
- arch: x86_64
target: x86_64-unknown-linux-gnu
runner: ubuntu-22.04
- arch: aarch64
target: aarch64-unknown-linux-gnu
runner: ubuntu-22.04-arm
- arch: macos-arm64
target: aarch64-apple-darwin
runner: macos-latest
- arch: macos-x86_64
target: x86_64-apple-darwin
runner: macos-latest
runs-on: ${{ matrix.runner }}
steps:
- name: Check out repository with submodules
uses: actions/checkout@v4.1.4
with:
submodules: recursive # This will fetch all submodules recursively
fetch-depth: 1 # Shallow clone is sufficient and faster
- name: Update version in Cargo.toml
run: |
# Get current date in YYYY.MM.DD format
DATE=$(date +'%Y.%-m.%-d')
# Get time in HH.MM format
TIME=$(date +'%H%M')
# Create new version string
NEW_VERSION="${DATE}+${TIME}"
# Update version in Cargo.toml (compatible with both macOS and Linux)
if [[ "${{ matrix.runner }}" == *"macos"* ]]; then
sed -i '' "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" Cargo.toml
else
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" Cargo.toml
fi
# Print the new version for verification
echo "Updated version to: ${NEW_VERSION}"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install target
run: rustup target add ${{ matrix.target }}
- name: Cache Rust dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-deps-${{ matrix.target }}-stable-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-deps-${{ matrix.target }}-stable-
- name: Cache build artifacts
id: cache-build
uses: actions/cache@v4
with:
path: |
target/
key: cargo-build-${{ matrix.target }}-stable-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-build-${{ matrix.target }}-stable-
- name: Install build dependencies
run: |
if [[ "${{ matrix.runner }}" == *"ubuntu"* ]]; then
rustup toolchain install nightly-2025-04-15 --component rust-src
sudo apt-get update
sudo apt-get install -y linux-headers-$(uname -r) libbpf-dev clang llvm libelf-dev libssl-dev pkg-config
fi
# Verify submodules are properly loaded
- name: Verify submodule content
run: |
# Find all vmlinux.h files
vmlinux_files=$(find vendor -name "vmlinux.h")
# Check if any vmlinux.h files exist
if [ -z "$vmlinux_files" ]; then
echo "ERROR: No vmlinux.h files found in vendor directory"
exit 1
fi
# Print out the found vmlinux.h files for debugging
echo "Found vmlinux.h files:"
echo "$vmlinux_files"
# Optional: Check for specific directories or files you expect
if [ ! -d "vendor/bpftool" ] || [ ! -d "vendor/libbpf" ]; then
echo "WARNING: Expected vendor subdirectories are missing"
fi
- name: Build the binary
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_INCREMENTAL: "0"
BUILD_CHANNEL: ${{ matrix.channel }}
run: cargo build --release --target ${{ matrix.target }} -p tracer -p tracer-installer
- name: Prepare binary for release
run: |
mkdir -p release-files/${{ matrix.arch }}
cp target/${{ matrix.target }}/release/tracer release-files/${{ matrix.arch }}/tracer
chmod +x release-files/${{ matrix.arch }}/tracer
tar -czf release-files/tracer-${{ matrix.channel }}-${{ matrix.target }}.tar.gz -C release-files/${{ matrix.arch }} tracer
if [ -f target/${{ matrix.target }}/release/tracer-installer ]; then
cp target/${{ matrix.target }}/release/tracer-installer release-files/${{ matrix.arch }}/tracer-installer
chmod +x release-files/${{ matrix.arch }}/tracer-installer
tar -czf release-files/tracer-installer-${{ matrix.target }}.tar.gz -C release-files/${{ matrix.arch }} tracer-installer
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Upload to S3
run: |
aws s3 cp release-files/tracer-${{ matrix.channel }}-${{ matrix.target }}.tar.gz s3://tracer-releases/tracer-${{ matrix.channel }}-${{ matrix.target }}.tar.gz
aws s3 cp release-files/tracer-${{ matrix.channel }}-${{ matrix.target }}.tar.gz s3://tracer-releases/${{ github.head_ref || github.ref_name }}/tracer-${{ matrix.channel }}-${{ matrix.target }}.tar.gz
if [ -f release-files/tracer-installer-${{ matrix.target }}.tar.gz ]; then
aws s3 cp release-files/tracer-installer-${{ matrix.target }}.tar.gz s3://tracer-installer-releases/${{ github.head_ref || github.ref_name }}/tracer-installer-${{ matrix.target }}.tar.gz
fi
build-and-release-amazon-linux:
permissions: write-all
strategy:
matrix:
channel: [dev, prod]
runs-on: ubuntu-latest
container:
image: amazonlinux:2023
steps:
- name: Cache Rust dependencies (Amazon Linux)
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: amazon-linux-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
amazon-linux-cargo-
- name: Install dependencies
run: |
yum update -y --allowerasing
yum groupinstall -y "Development Tools" --allowerasing
yum install -y kernel-devel kernel-headers clang llvm libbpf-devel openssl-devel pkgconfig --allowerasing
- name: Install Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo 'source $HOME/.cargo/env' >> ~/.bashrc
source $HOME/.cargo/env
rustup target add x86_64-unknown-linux-gnu
rustup toolchain install nightly-2025-04-15 --component rust-src
- name: Check out repository with submodules
uses: actions/checkout@v4.1.4
with:
submodules: recursive # This will fetch all submodules recursively
fetch-depth: 0 # Fetch all history for versioning
- name: Configure Git safe directory
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Update version in Cargo.toml
run: |
# Get current date in YYYY.MM.DD format
DATE=$(date +'%Y.%-m.%-d')
# Get time in HH.MM format
TIME=$(date +'%H%M')
# Create new version string
NEW_VERSION="${DATE}+${TIME}"
# Update version in Cargo.toml
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" Cargo.toml
# Print the new version for verification
echo "Updated version to: ${NEW_VERSION}"
- name: Build the binary
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_INCREMENTAL: "0"
BUILD_CHANNEL: ${{ matrix.channel }}
run: |
source $HOME/.cargo/env
cargo build --release -p tracer
- name: Prepare binary for release
run: |
mkdir -p release-files/amazon-linux
cp target/release/tracer release-files/amazon-linux/tracer
chmod +x release-files/amazon-linux/tracer
tar -czf release-files/tracer-${{ matrix.channel }}-x86_64-amazon-linux-gnu.tar.gz -C release-files/amazon-linux tracer
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Upload to S3
run: |
aws s3 cp release-files/tracer-${{ matrix.channel }}-x86_64-amazon-linux-gnu.tar.gz s3://tracer-releases/tracer-${{ matrix.channel }}-x86_64-amazon-linux-gnu.tar.gz
aws s3 cp release-files/tracer-${{ matrix.channel }}-x86_64-amazon-linux-gnu.tar.gz s3://tracer-releases/${{ github.head_ref || github.ref_name }}/tracer-${{ matrix.channel }}-x86_64-amazon-linux-gnu.tar.gz