Skip to content

Commit 3e11dfd

Browse files
committed
build: statically link OpenSSL on Linux
1 parent 6d83475 commit 3e11dfd

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: publish
22

33
on:
4+
pull_request:
45
push:
56
tags:
67
- "v*"
@@ -18,13 +19,13 @@ jobs:
1819
- name: Setup Rust
1920
uses: dtolnay/rust-toolchain@stable
2021

21-
- name: Confirm tag matches Cargo.toml
22+
- name: Read and verify version
2223
id: version
2324
shell: bash
2425
run: |
2526
set -euo pipefail
2627
version="$(cargo metadata --no-deps --format-version 1 | jq -er '.packages[0].version')"
27-
if [[ "$GITHUB_REF_TYPE" != "tag" || "$GITHUB_REF_NAME" != "v$version" ]]; then
28+
if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF_NAME" != "v$version" ]]; then
2829
echo "::error::Tag $GITHUB_REF_NAME does not match Cargo.toml version $version."
2930
exit 1
3031
fi
@@ -54,8 +55,10 @@ jobs:
5455

5556
build:
5657
name: Build for ${{ matrix.target }}
57-
needs: [create-release]
58-
if: startsWith(github.ref, 'refs/tags/')
58+
needs: [verify, create-release]
59+
if: >-
60+
always() && needs.verify.result == 'success' &&
61+
(github.event_name == 'pull_request' || needs.create-release.result == 'success')
5962
runs-on: ${{ matrix.os }}
6063
permissions:
6164
contents: read
@@ -89,9 +92,29 @@ jobs:
8992
- name: Cache Rust
9093
uses: Swatinem/rust-cache@v2
9194

95+
- name: Build (Linux, static OpenSSL)
96+
if: runner.os == 'Linux'
97+
env:
98+
OPENSSL_STATIC: "1"
99+
run: cargo build --verbose --bin=wb --release --locked --target=${{ matrix.target }}
100+
92101
- name: Build
102+
if: runner.os != 'Linux'
93103
run: cargo build --verbose --bin=wb --release --locked --target=${{ matrix.target }}
94104

105+
- name: Verify Linux linkage
106+
if: runner.os == 'Linux'
107+
shell: bash
108+
run: |
109+
set -euo pipefail
110+
binary="target/${{ matrix.target }}/release/wb"
111+
if ldd "$binary" | grep -Eq 'lib(ssl|crypto)\.so'
112+
then
113+
echo "::error::Linux release must not dynamically link OpenSSL."
114+
ldd "$binary"
115+
exit 1
116+
fi
117+
95118
- name: Package (unix)
96119
if: matrix.archive == 'tar.gz'
97120
run: |

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "weibian"
3-
version = "2.0.0-rc.4"
3+
version = "2.0.0-rc.5"
44
edition = "2024"
55

66
[[bin]]

0 commit comments

Comments
 (0)