-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (164 loc) · 5.96 KB
/
Copy pathartifacts.yml
File metadata and controls
197 lines (164 loc) · 5.96 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
name: Build Artifacts
on:
workflow_dispatch:
inputs:
commit_to_main:
description: Commit prebuilt libs to main (release prep)
type: boolean
default: false
push:
branches: [main]
tags: ["v*"]
jobs:
build-linux:
name: Build Linux Libs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && inputs.commit_to_main) && 'main' || github.ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
- name: Install cargo-zigbuild
run: |
pip install ziglang
cargo install cargo-zigbuild
- name: Build AMD64
run: |
# glibc (2.17 for broad compatibility)
cargo zigbuild --release --target x86_64-unknown-linux-gnu.2.17 -p seekable-zstd-core
# musl
cargo zigbuild --release --target x86_64-unknown-linux-musl -p seekable-zstd-core
- name: Build ARM64
run: |
# glibc (2.17)
cargo zigbuild --release --target aarch64-unknown-linux-gnu.2.17 -p seekable-zstd-core
# musl
cargo zigbuild --release --target aarch64-unknown-linux-musl -p seekable-zstd-core
- name: Organize Artifacts
shell: bash
run: |
set -euo pipefail
copy_lib() {
target="$1"
dest_dir="$2"
# cargo-zigbuild glibc targets may emit to either:
# - target/<triple>.2.17/... (as invoked)
# - target/<triple>/... (canonical directory)
candidates=("$target")
case "$target" in
*.2.17) candidates+=("${target%.2.17}") ;;
esac
for candidate in "${candidates[@]}"; do
src="target/${candidate}/release/libseekable_zstd_core.a"
if [ -f "$src" ]; then
mkdir -p "$dest_dir"
cp "$src" "$dest_dir/"
return 0
fi
done
echo "❌ missing libseekable_zstd_core.a for target: $target"
echo "Found these candidate outputs:"
find target -maxdepth 4 -path '*/release/libseekable_zstd_core.a' -print || true
exit 1
}
copy_lib x86_64-unknown-linux-gnu.2.17 dist/linux-amd64
copy_lib x86_64-unknown-linux-musl dist/linux-amd64-musl
copy_lib aarch64-unknown-linux-gnu.2.17 dist/linux-arm64
copy_lib aarch64-unknown-linux-musl dist/linux-arm64-musl
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-libs
path: dist/*
build-macos:
name: Build macOS Libs
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && inputs.commit_to_main) && 'main' || github.ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin,aarch64-apple-darwin
- name: Build
env:
# Build for broad compatibility.
MACOSX_DEPLOYMENT_TARGET: "11.0"
run: |
cargo build --release --target x86_64-apple-darwin -p seekable-zstd-core
cargo build --release --target aarch64-apple-darwin -p seekable-zstd-core
- name: Organize Artifacts
run: |
mkdir -p dist/darwin-amd64
cp target/x86_64-apple-darwin/release/libseekable_zstd_core.a dist/darwin-amd64/
mkdir -p dist/darwin-arm64
cp target/aarch64-apple-darwin/release/libseekable_zstd_core.a dist/darwin-arm64/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: macos-libs
path: dist/*
build-windows:
name: Build Windows Libs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && inputs.commit_to_main) && 'main' || github.ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-gnu
- name: Install cargo-zigbuild
run: |
pip install ziglang
cargo install cargo-zigbuild
- name: Build AMD64
run: |
cargo zigbuild --release --target x86_64-pc-windows-gnu -p seekable-zstd-core
- name: Organize Artifacts
run: |
mkdir -p dist/windows-amd64
cp target/x86_64-pc-windows-gnu/release/libseekable_zstd_core.a dist/windows-amd64/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: windows-libs
path: dist/*
commit-artifacts:
name: Commit Artifacts
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_to_main }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 1
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: download-libs
- name: Organize artifacts
run: |
# The download-artifact action downloads to download-libs/{artifact-name}/*
# We need to move them to bindings/go/lib/{arch}/
# Linux
cp -r download-libs/linux-libs/* bindings/go/lib/
# macOS
cp -r download-libs/macos-libs/* bindings/go/lib/
# Windows
cp -r download-libs/windows-libs/* bindings/go/lib/
echo "Artifact structure:"
ls -R bindings/go/lib
- name: Commit and Push
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update pre-built static libraries"
file_pattern: "bindings/go/lib/**"