Files
M0re Co1ors 2a23ce8736 perf(musl,tls,relay): native Alpine 3.24 musl builds, TLS cache fixes, and idle relay buffer shrink (#547)
* build(musl): replace Zig cross wrappers with native Alpine 3.24 builds

* fix(tls,core): cache DNS TLS connectors, bound caches, and add jemalloc-stats feature

* perf(relay): shrink idle expanded TCP copy buffers in place after 60s

* chore(changelog): add feat-memory-opt changelog fragment
2026-11-26 22:05:31 +08:00

473 lines
22 KiB
YAML

name: Release
on:
push:
tags: ["v*", "debug.*"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ startsWith(github.ref, 'refs/tags/debug.') && 'release-debug' || format('ci-{0}-{1}', github.workflow, github.run_id) }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: cargo test (workspace)
runs-on: ubuntu-24.04
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Test release artifact preflight
run: bash .github/ci/test-release-artifacts.sh
- name: Test Debug release pruning
run: bash .github/ci/test-release-prune.sh
- name: Test release asset table
run: bash .github/ci/test-release-assets.sh
- name: Test release version and notes scripts
run: |
bash .github/ci/test-release-version.sh
bash .github/ci/test-release-notes.sh
# A formal tag must be SemVer and equal the workspace version. The builds run
# in parallel; the release job needs this one, so a mismatched tag publishes nothing.
- name: Check the tag against the workspace version
if: startsWith(github.ref, 'refs/tags/v')
run: bash .github/ci/check-release-version.sh "$GITHUB_REF_NAME"
- name: Read Rust toolchain
id: toolchain
run: echo "stable=$(grep -oP '^channel\s*=\s*\"\K[^\"]+' rust-toolchain.toml)" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: ${{ steps.toolchain.outputs.stable }}
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
cache-on-failure: true
save-if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
- name: Install boring-sys build deps (cmake + libclang for bindgen)
run: |
set -euo pipefail
sudo apt-get -o Acquire::Retries=5 update
sudo apt-get -o Acquire::Retries=5 install -y cmake libclang-dev
# routing::tests::test_geosite_* need geo assets (locally found at
# /etc/dae/geosite.dat; the runner has none).
- name: Read geo cache key
id: geo-pins
run: |
set -euo pipefail
source .github/ci/pins.env
echo "key=$GEOSITE_SHA256-$GEOIP_SHA256" >> "$GITHUB_OUTPUT"
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/geo-assets
key: geo-${{ steps.geo-pins.outputs.key }}
- name: Install geo assets for the geosite tests
run: |
set -euo pipefail
source .github/ci/pins.env
geo_dir="$RUNNER_TEMP/geo-assets"
mkdir -p "$geo_dir"
if ! test -f "$geo_dir/geosite.dat"; then
curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 -o "$geo_dir/geosite.dat" \
"https://github.com/v2fly/domain-list-community/releases/download/$GEOSITE_TAG/dlc.dat"
fi
if ! test -f "$geo_dir/geoip.dat"; then
curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 -o "$geo_dir/geoip.dat" \
"https://github.com/v2fly/geoip/releases/download/$GEOIP_TAG/geoip.dat"
fi
echo "$GEOSITE_SHA256 $geo_dir/geosite.dat" | sha256sum -c -
echo "$GEOIP_SHA256 $geo_dir/geoip.dat" | sha256sum -c -
sudo install -D -m 0644 "$geo_dir/geosite.dat" /etc/dae/geosite.dat
sudo install -D -m 0644 "$geo_dir/geoip.dat" /etc/dae/geoip.dat
- run: cargo test --workspace --no-fail-fast
build-ebpf:
name: build eBPF object
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Read eBPF Rust toolchain
id: toolchain
run: echo "ebpf=$(grep -oP '^channel\s*=\s*\"\K[^\"]+' crates/honk-ebpf/rust-toolchain.toml)" >> "$GITHUB_OUTPUT"
- name: Install Rust nightly (for the eBPF object)
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: ${{ steps.toolchain.outputs.ebpf }}
components: rust-src, llvm-tools
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
key: ebpf-${{ steps.toolchain.outputs.ebpf }}
cache-on-failure: true
save-if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
workspaces: |
crates/honk-ebpf -> target
- name: Install zstd
run: |
set -euo pipefail
sudo apt-get -o Acquire::Retries=5 update
sudo apt-get -o Acquire::Retries=5 install -y zstd
- name: Install pinned bpf-linker
run: |
set -euo pipefail
source .github/ci/pins.env
curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 -o "$RUNNER_TEMP/bpf-linker.tar.zst" \
"https://github.com/aya-rs/bpf-linker/releases/download/v$BPF_LINKER_VERSION/bpf-linker-x86_64-unknown-linux-musl.tar.zst"
echo "$BPF_LINKER_SHA256 $RUNNER_TEMP/bpf-linker.tar.zst" | sha256sum -c -
zstd -dc "$RUNNER_TEMP/bpf-linker.tar.zst" | tar -xf - -C "$CARGO_HOME/bin"
bpf-linker --version
# The eBPF object is target-independent; build it once on x86_64 so all
# downstream matrix jobs (including native arm64) reuse the verified object.
- name: Build and verify eBPF object
working-directory: crates/honk-ebpf
env:
EBPF_TOOLCHAIN: ${{ steps.toolchain.outputs.ebpf }}
run: |
set -euo pipefail
cargo build --release -Zbuild-std=core --target bpfel-unknown-none
# aya refuses objects without BTF ("no BTF parsed for object") — fail
# the build here instead of at runtime on a gateway.
readelf -S target/bpfel-unknown-none/release/honk-ebpf | grep -q '\.BTF'
# build.rs requires the exact compiler channel without a trailing newline.
printf '%s' "$EBPF_TOOLCHAIN" > target/bpfel-unknown-none/release/honk-ebpf.toolchain
- name: Upload eBPF object
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: honk-ebpf
path: |
crates/honk-ebpf/target/bpfel-unknown-none/release/honk-ebpf
crates/honk-ebpf/target/bpfel-unknown-none/release/honk-ebpf.toolchain
retention-days: 1
if-no-files-found: error
build:
name: build ${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }}
needs: [build-ebpf]
runs-on: ${{ matrix.runner }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
# Full: Clash API + native API + embedded doona UI. Both arches ship
# two binaries: jemalloc (default, faster QUIC) and stock malloc
# (lower RSS high-water on small gateways).
- {target: x86_64-unknown-linux-gnu, runner: ubuntu-24.04, suffix: "", variant: full, name_suffix: "-full"}
- {target: x86_64-unknown-linux-gnu, runner: ubuntu-24.04, suffix: "-stock", variant: full, name_suffix: "-full"}
- {target: x86_64-unknown-linux-musl, runner: ubuntu-24.04, suffix: "", variant: full, name_suffix: "-full"}
- {target: x86_64-unknown-linux-musl, runner: ubuntu-24.04, suffix: "-stock", variant: full, name_suffix: "-full"}
- {target: aarch64-unknown-linux-gnu, runner: ubuntu-24.04-arm, suffix: "", variant: full, name_suffix: "-full"}
- {target: aarch64-unknown-linux-gnu, runner: ubuntu-24.04-arm, suffix: "-stock", variant: full, name_suffix: "-full"}
- {target: aarch64-unknown-linux-musl, runner: ubuntu-24.04-arm, suffix: "", variant: full, name_suffix: "-full"}
- {target: aarch64-unknown-linux-musl, runner: ubuntu-24.04-arm, suffix: "-stock", variant: full, name_suffix: "-full"}
# Lean variants apply to the static gateway builds only; the gnu
# artifacts stay full. Every name carries its variant suffix.
- {target: x86_64-unknown-linux-musl, runner: ubuntu-24.04, suffix: "", variant: clash-api, name_suffix: "-clash-api"}
- {target: x86_64-unknown-linux-musl, runner: ubuntu-24.04, suffix: "-stock", variant: clash-api, name_suffix: "-clash-api"}
- {target: aarch64-unknown-linux-musl, runner: ubuntu-24.04-arm, suffix: "", variant: clash-api, name_suffix: "-clash-api"}
- {target: aarch64-unknown-linux-musl, runner: ubuntu-24.04-arm, suffix: "-stock", variant: clash-api, name_suffix: "-clash-api"}
- {target: x86_64-unknown-linux-musl, runner: ubuntu-24.04, suffix: "", variant: native-api, name_suffix: "-native-api"}
- {target: x86_64-unknown-linux-musl, runner: ubuntu-24.04, suffix: "-stock", variant: native-api, name_suffix: "-native-api"}
- {target: aarch64-unknown-linux-musl, runner: ubuntu-24.04-arm, suffix: "", variant: native-api, name_suffix: "-native-api"}
- {target: aarch64-unknown-linux-musl, runner: ubuntu-24.04-arm, suffix: "-stock", variant: native-api, name_suffix: "-native-api"}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
# Manual runs can select a branch whose name contains '/', which cannot
# appear in an asset path. Tags keep the existing debug/v* spelling.
- name: Resolve artifact name
run: |
set -euo pipefail
if [[ "$GITHUB_REF" == refs/tags/debug.* ]]; then
prefix=debug
else
prefix=${GITHUB_REF_NAME//\//-}
fi
echo "ARTIFACT_NAME=honk-core-$prefix-${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }}" >> "$GITHUB_ENV"
- name: Read Rust toolchain
id: toolchain
run: echo "stable=$(grep -oP '^channel\s*=\s*\"\K[^\"]+' rust-toolchain.toml)" >> "$GITHUB_OUTPUT"
- name: Install Rust stable
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: ${{ steps.toolchain.outputs.stable }}
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
key: ${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }}
cache-on-failure: true
save-if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
- name: Download eBPF object
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: honk-ebpf
path: crates/honk-ebpf/target/bpfel-unknown-none/release
- name: Verify and stamp eBPF object
run: |
set -euo pipefail
ebpf=crates/honk-ebpf/target/bpfel-unknown-none/release/honk-ebpf
expected=$(grep -oP '^channel\s*=\s*"\K[^"]+' crates/honk-ebpf/rust-toolchain.toml)
readelf -S "$ebpf" | grep -q '\.BTF'
cmp -s "${ebpf}.toolchain" <(printf '%s' "$expected")
# Download preserves no mtime newer than checkout; stamp both so build.rs
# embeds this object without invoking nightly cargo.
touch "$ebpf" "${ebpf}.toolchain"
- name: Install boring-sys build deps (gnu)
if: endsWith(matrix.target, '-gnu')
run: |
set -euo pipefail
sudo apt-get -o Acquire::Retries=5 update
sudo apt-get -o Acquire::Retries=5 install -y cmake libclang-dev
- name: Fetch doona for the embedded UI
if: matrix.variant == 'full'
run: |
set -euo pipefail
dir=$(ci/fetch-doona.sh)
echo "HONK_DOONA_DIR=$dir" >> "$GITHUB_ENV"
# The release builds from an exact feature set: `--no-default-features`
# below means the native-api-only variant really drops the default-on
# clash-api. Allocator variants keep the same protocol and API features.
- name: Resolve feature set
shell: bash
run: |
set -euo pipefail
case "${{ matrix.variant }}" in
full) features=clash-api,native-ui ;;
clash-api) features=clash-api ;;
native-api) features=native-api ;;
*) printf 'unknown variant: %s\n' "${{ matrix.variant }}" >&2; exit 1 ;;
esac
features="ebpf,rprx,$features"
if [[ "${{ matrix.suffix }}" != "-stock" ]]; then
features+=,jemalloc
fi
echo "FEATURES=$features" >> "$GITHUB_ENV"
- name: Build honk-core (native gnu)
if: endsWith(matrix.target, '-gnu')
run: cargo build --release -p honk-core --no-default-features --features "$FEATURES" --target ${{ matrix.target }}
- name: Build honk-core (native musl via Alpine 3.24)
if: endsWith(matrix.target, '-musl')
run: ci/build-musl.sh honk-core --no-default-features --features "$FEATURES"
- name: Package artifact
run: |
set -euo pipefail
name="$ARTIFACT_NAME"
mkdir -p "dist/$name"
cp "target/${{ matrix.target }}/release/honk-core" "dist/$name/"
cp LICENSE README.md "dist/$name/"
# Both editions keep their own notices. Their GPL-3.0-only license must
# match the top-level LICENSE; lean variants embed neither edition.
if [[ "${{ matrix.variant }}" == full ]]; then
for edition in doona doona-lite; do
ui_dir="$HONK_DOONA_DIR"
[[ "$edition" != doona-lite ]] || ui_dir="${HONK_DOONA_DIR%/}-lite"
if ! cmp -s LICENSE "$ui_dir/LICENSE"; then
echo "::error::$edition's LICENSE differs from honk's; ship it under $edition/ again"
exit 1
fi
mkdir "dist/$name/$edition"
cp -r "$ui_dir"/{LICENSES,NOTICE,THIRD-PARTY-NOTICES.txt} "dist/$name/$edition/"
done
fi
tar -czf "$name.tar.gz" -C dist "$name"
- name: Start the packaged artifact
run: |
set -euo pipefail
smoke_dir=$(mktemp -d "$RUNNER_TEMP/release-smoke.XXXXXX")
trap 'rm -rf "$smoke_dir"' EXIT
tar -xzf "$ARTIFACT_NAME.tar.gz" -C "$smoke_dir"
"$smoke_dir/$ARTIFACT_NAME/honk-core" --version
- name: Upload artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: honk-core-${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }}
path: ${{ env.ARTIFACT_NAME }}.tar.gz
retention-days: 1
release:
name: GitHub Release
needs: [test, build]
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
id-token: write
attestations: write
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/debug.')
steps:
- name: Download all artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: honk-core-*
path: dist
merge-multiple: true
- name: Checkout release source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
path: release-source
# The comparison link needs the previous v* tag.
fetch-depth: 0
# Retrying only this job after the one-day artifact retention would otherwise publish a partial set.
- name: Check complete release artifacts
run: |
if [[ "$GITHUB_REF" == refs/tags/debug.* ]]; then
bash release-source/.github/ci/check-release-artifacts.sh debug
else
bash release-source/.github/ci/check-release-artifacts.sh "$GITHUB_REF_NAME"
fi
# GPL-3.0 section 6: both embedded editions share this corresponding source.
- name: Add doona corresponding source
run: bash release-source/ci/fetch-doona.sh --source dist
# Formal releases also package the static musl full builds for dpkg, rpm and pacman.
- name: Build Linux packages
if: startsWith(github.ref, 'refs/tags/v')
working-directory: release-source
run: |
set -euo pipefail
source .github/ci/pins.env
curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 -o "$RUNNER_TEMP/nfpm.tar.gz" \
"https://github.com/goreleaser/nfpm/releases/download/v$NFPM_VERSION/nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz"
echo "$NFPM_SHA256 $RUNNER_TEMP/nfpm.tar.gz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/nfpm.tar.gz" -C "$RUNNER_TEMP" nfpm
PATH="$RUNNER_TEMP:$PATH" bash .github/ci/build-packages.sh ../dist "$GITHUB_REF_NAME"
# One checksum file covers every published archive, formal and Debug alike; the
# attestation lets `gh attestation verify` tie each archive to this workflow run.
- name: Write SHA256SUMS
working-directory: dist
run: |
shopt -s nullglob
sha256sum -- *.tar.gz *.deb *.rpm *.pkg.tar.zst > SHA256SUMS
# Every release body explains each archive as {allocator}-{API}-{arch}-{libc}.
- name: Write release notes
env:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
bash release-source/.github/ci/release-assets.sh dist > assets.md
source_lines=$(printf "Source tag: \`%s\`\n\nCommit: \`%s\`\n\nBuild: %s" "$GITHUB_REF_NAME" "$GITHUB_SHA" "$RUN_URL")
printf "Debug build of \`%s\`.\n\n%s\n\n" "$GITHUB_REF_NAME" "$source_lines" | cat - assets.md > notes-debug.md
printf 'Rolling debug build: the newest published debug tag. Each tag also keeps its own release.\n\n%s\n\n' "$source_lines" | cat - assets.md > notes-rolling.md
- name: Write formal release notes
if: startsWith(github.ref, 'refs/tags/v')
run: |
(cd release-source && bash .github/ci/release-notes.sh "$GITHUB_REF_NAME" ../assets.md) > notes-formal.md
- name: Attest build provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-checksums: dist/SHA256SUMS
# A formal release starts as a draft: the maintainer writes the Highlights,
# checks the assets, then publishes it. Debug releases stay immediate.
- name: Create release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
with:
files: |
dist/*.tar.gz
dist/*.deb
dist/*.rpm
dist/*.pkg.tar.zst
dist/SHA256SUMS
fail_on_unmatched_files: true
prerelease: ${{ contains(github.ref_name, '-') }}
draft: true
body_path: notes-formal.md
- name: Publish Debug release
if: startsWith(github.ref, 'refs/tags/debug.')
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
target_commitish: ${{ github.sha }}
prerelease: true
make_latest: "false"
files: |
dist/*.tar.gz
dist/SHA256SUMS
overwrite_files: true
fail_on_unmatched_files: true
body_path: notes-debug.md
# The rolling Debug release keeps one stable page and download URL on the newest published build; the tag release
# above stays as the immutable copy that downstream pins name.
- name: Move rolling Debug tag
if: startsWith(github.ref, 'refs/tags/debug.')
working-directory: release-source
run: git push --force origin "$GITHUB_SHA:refs/tags/debug"
# The fixed honk-core names overwrite in place; the doona source archive is named by version, so the previous one
# is removed rather than left beside the new one.
- name: Drop stale rolling Debug assets
if: startsWith(github.ref, 'refs/tags/debug.')
env:
GH_TOKEN: ${{ github.token }}
run: |
# No Debug release yet means nothing to drop; the next step creates it. Any other error fails the step,
# so a stale doona source archive cannot stay beside the new SHA256SUMS.
if ! names=$(gh release view debug --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' 2> view.err); then
grep -qx 'release not found' view.err && exit 0
cat view.err >&2
exit 1
fi
for name in $names; do
[[ -e "dist/$name" ]] || gh release delete-asset debug "$name" --repo "$GITHUB_REPOSITORY" --yes
done
- name: Update rolling Debug release
if: startsWith(github.ref, 'refs/tags/debug.')
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
with:
tag_name: debug
name: Debug
target_commitish: ${{ github.sha }}
prerelease: true
make_latest: "false"
files: |
dist/*.tar.gz
dist/SHA256SUMS
overwrite_files: true
fail_on_unmatched_files: true
body_path: notes-rolling.md
# Downstream pins name a per-tag Debug release, so the newest ten stay; older
# ones are removed from the Releases page while their source tags remain.
# Order by publication: a release's createdAt is its target commit's date. Re-running an older tag keeps its
# original publishedAt, so the tag just published is excluded explicitly and nine others stay beside it.
- name: Prune old Debug releases
if: startsWith(github.ref, 'refs/tags/debug.')
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release list --repo "$GITHUB_REPOSITORY" --limit 1000 --json tagName,publishedAt |
bash release-source/.github/ci/release-prune.sh |
while read -r tag; do
gh release delete "$tag" --repo "$GITHUB_REPOSITORY" --yes
done