-
Notifications
You must be signed in to change notification settings - Fork 3
136 lines (120 loc) · 3.98 KB
/
release.yml
File metadata and controls
136 lines (120 loc) · 3.98 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
name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
os: macos-latest
cross: false
- target: aarch64-apple-darwin
os: macos-latest
cross: false
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --version 0.2.5
- name: Build
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Verify static linking
if: contains(matrix.target, 'linux-musl')
run: |
binary="target/${{ matrix.target }}/release/clickhousectl"
echo "--- file output ---"
file "$binary"
file "$binary" | grep -qE "statically linked|static-pie linked"
echo "--- ldd output ---"
ldd_output=$(ldd "$binary" 2>&1 || true)
echo "$ldd_output"
echo "$ldd_output" | grep -qE "not a dynamic executable|statically linked"
echo "Static linking verified."
- name: Rename binary
run: cp target/${{ matrix.target }}/release/clickhousectl clickhousectl-${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: clickhousectl-${{ matrix.target }}
path: clickhousectl-${{ matrix.target }}
smoke-test:
name: Smoke test (${{ matrix.distro }})
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- distro: ubuntu:20.04
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: ubuntu:22.04
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: ubuntu:24.04
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: debian:bullseye
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: debian:bookworm
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: centos:7
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: amazonlinux:2
artifact: clickhousectl-x86_64-unknown-linux-musl
- distro: alpine:3.18
artifact: clickhousectl-x86_64-unknown-linux-musl
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
- name: Run smoke test in ${{ matrix.distro }}
run: |
chmod +x ${{ matrix.artifact }}
docker run --rm \
-v "$PWD/${{ matrix.artifact }}:/usr/local/bin/clickhousectl:ro" \
${{ matrix.distro }} \
sh -c 'clickhousectl --version && clickhousectl --help'
release:
name: Create Release
needs: [build, smoke-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Collect binaries
run: |
mkdir release
for dir in artifacts/clickhousectl-*/; do
cp "$dir"/* release/
done
- name: Create GitHub Release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe #v2
with:
generate_release_notes: true
files: release/*