From 120d4f1c6cba75a58ff15a6567d64e319c410aab Mon Sep 17 00:00:00 2001 From: Kohei Taniguchi Date: Mon, 13 Apr 2026 17:28:55 +0900 Subject: [PATCH 1/4] Add musl target builds for glibc-independent binary distribution - Add x86_64-unknown-linux-musl and aarch64-unknown-linux-musl to build matrix - Use cross-rs for musl cross-compilation in Docker containers - Add gmp-mpfr-sys with force-cross feature for musl builds - Conditionally set binary path for cross vs cargo builds - Restrict publish-crate and release jobs to tag pushes only - Add branch trigger for build testing - Bump version to 0.5.8 Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++------ .gitignore | 1 + Cargo.lock | 3 +- Cargo.toml | 6 +++- Cross.toml | 5 +++ 5 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 Cross.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bd809d..45ee403 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,8 @@ on: push: tags: - 'v*' + branches: + - 'task-161-add-musl-static-build-for-release' env: CARGO_INCREMENTAL: 0 @@ -18,14 +20,27 @@ jobs: runner: ubuntu-latest artifact_name: electrs platform: x86_64-linux-gnu + use_cross: false - target: aarch64-unknown-linux-gnu runner: ubuntu-24.04-arm artifact_name: electrs platform: aarch64-linux-gnu + use_cross: false - target: aarch64-apple-darwin runner: macos-14 artifact_name: electrs platform: aarch64-apple-darwin + use_cross: false + - target: x86_64-unknown-linux-musl + runner: ubuntu-latest + artifact_name: electrs + platform: x86_64-linux-musl + use_cross: true + - target: aarch64-unknown-linux-musl + runner: ubuntu-24.04-arm + artifact_name: electrs + platform: aarch64-linux-musl + use_cross: true runs-on: ${{ matrix.runner }} steps: @@ -34,7 +49,12 @@ jobs: - name: Get version id: version - run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + run: | + if [[ "$GITHUB_REF" == refs/tags/* ]]; then + echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + else + echo "tag=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT + fi - name: Install Rust uses: dtolnay/rust-toolchain@stable @@ -50,17 +70,37 @@ jobs: target/ key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build + - name: Install cross + if: matrix.use_cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Build (cross) + if: matrix.use_cross + run: cross build --release --locked --target ${{ matrix.target }} + + - name: Build (cargo) + if: ${{ !matrix.use_cross }} run: cargo build --release --locked + - name: Set binary path + id: binary + run: | + if [ "${{ matrix.use_cross }}" = "true" ]; then + echo "path=target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" >> $GITHUB_OUTPUT + echo "dir=target/${{ matrix.target }}/release" >> $GITHUB_OUTPUT + else + echo "path=target/release/${{ matrix.artifact_name }}" >> $GITHUB_OUTPUT + echo "dir=target/release" >> $GITHUB_OUTPUT + fi + - name: Strip binary - run: strip target/release/${{ matrix.artifact_name }} + run: strip ${{ steps.binary.outputs.path }} - name: Create tarball env: ASSET_NAME: electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }} run: | - cd target/release + cd ${{ steps.binary.outputs.dir }} tar czvf ${ASSET_NAME}.tar.gz ${{ matrix.artifact_name }} - name: Compute SHA256 (Linux) @@ -68,7 +108,7 @@ jobs: env: ASSET_NAME: electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }} run: | - cd target/release + cd ${{ steps.binary.outputs.dir }} sha256sum ${ASSET_NAME}.tar.gz > ${ASSET_NAME}.tar.gz.sha256 - name: Compute SHA256 (macOS) @@ -76,7 +116,7 @@ jobs: env: ASSET_NAME: electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }} run: | - cd target/release + cd ${{ steps.binary.outputs.dir }} shasum -a 256 ${ASSET_NAME}.tar.gz > ${ASSET_NAME}.tar.gz.sha256 - name: Upload artifact @@ -84,10 +124,11 @@ jobs: with: name: electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }} path: | - target/release/electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }}.tar.gz - target/release/electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }}.tar.gz.sha256 + ${{ steps.binary.outputs.dir }}/electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }}.tar.gz + ${{ steps.binary.outputs.dir }}/electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }}.tar.gz.sha256 publish-crate: + if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - name: Checkout @@ -102,6 +143,7 @@ jobs: run: cargo publish release: + if: startsWith(github.ref, 'refs/tags/') needs: build runs-on: ubuntu-latest permissions: @@ -122,4 +164,4 @@ jobs: generate_release_notes: true files: | artifacts/**/*.tar.gz - artifacts/**/*.sha256 \ No newline at end of file + artifacts/**/*.sha256 diff --git a/.gitignore b/.gitignore index 8dbb109..d4073a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ target *.sublime* *~ *.pyc +.claude/ diff --git a/Cargo.lock b/Cargo.lock index a624ad7..176ba0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "esplora-tapyrus" -version = "0.5.7" +version = "0.5.8" dependencies = [ "arraydeque", "arrayref", @@ -494,6 +494,7 @@ dependencies = [ "dirs", "error-chain", "glob", + "gmp-mpfr-sys", "hex", "hyper", "hyperlocal", diff --git a/Cargo.toml b/Cargo.toml index e05279a..cf87590 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "esplora-tapyrus" -version = "0.5.7" +version = "0.5.8" authors = ["Chaintope Inc.", "Roman Zeyde (original author) "] description = "An efficient re-implementation of Electrum Server in Rust" license = "MIT" @@ -52,6 +52,10 @@ tokio = { version = "1", features = ["sync", "macros"] } version = "^0.5.0" features = ["use-serde"] +[dependencies.gmp-mpfr-sys] +version = "~1.6" +features = ["force-cross"] + [profile.release] lto = true panic = 'abort' diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..86f9812 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,5 @@ +[target.x86_64-unknown-linux-musl] +image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:main" + +[target.aarch64-unknown-linux-musl] +image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:main" From da8a8a36d7341af8c4fe852426caad4391e82763 Mon Sep 17 00:00:00 2001 From: Kohei Taniguchi Date: Mon, 13 Apr 2026 17:37:54 +0900 Subject: [PATCH 2/4] Fix aarch64-musl build: use x86_64 runner with cross toolchain symlinks - Move aarch64-unknown-linux-musl to ubuntu-latest (x86_64) runner since cross-rs Docker images are x86_64-only - Add pre-build symlinks in Cross.toml to bridge tool naming mismatch (GMP configure expects "aarch64-unknown-linux-musl-*" but cross-rs provides "aarch64-linux-musl-*") - Both musl targets verified: static-linked, glibc-independent binaries Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 2 +- Cross.toml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45ee403..87b9ed1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: platform: x86_64-linux-musl use_cross: true - target: aarch64-unknown-linux-musl - runner: ubuntu-24.04-arm + runner: ubuntu-latest artifact_name: electrs platform: aarch64-linux-musl use_cross: true diff --git a/Cross.toml b/Cross.toml index 86f9812..1460c19 100644 --- a/Cross.toml +++ b/Cross.toml @@ -3,3 +3,9 @@ image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:main" [target.aarch64-unknown-linux-musl] image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:main" +pre-build = [ + # GMP's configure looks for tools named "aarch64-unknown-linux-musl-*" + # but cross-rs provides them as "aarch64-linux-musl-*". + # Create symlinks to bridge the naming mismatch. + "sh -c 'for tool in /usr/local/bin/aarch64-linux-musl-*; do ln -sf \"$tool\" \"/usr/local/bin/aarch64-unknown-linux-musl-$(basename $tool | sed s/aarch64-linux-musl-//)\"; done'", +] From e32e71cc2e2111453bd262423f46d3a2837aad4c Mon Sep 17 00:00:00 2001 From: Kohei Taniguchi Date: Mon, 13 Apr 2026 17:48:16 +0900 Subject: [PATCH 3/4] Fix strip for cross-compiled aarch64-musl and add fail-fast: false - Use aarch64-linux-gnu-strip for aarch64 musl binary on x86_64 runner - Install binutils-aarch64-linux-gnu for cross-arch strip support - Add fail-fast: false so one build failure doesn't cancel others Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87b9ed1..5bb50e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,7 @@ env: jobs: build: strategy: + fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu @@ -21,26 +22,31 @@ jobs: artifact_name: electrs platform: x86_64-linux-gnu use_cross: false + strip: strip - target: aarch64-unknown-linux-gnu runner: ubuntu-24.04-arm artifact_name: electrs platform: aarch64-linux-gnu use_cross: false + strip: strip - target: aarch64-apple-darwin runner: macos-14 artifact_name: electrs platform: aarch64-apple-darwin use_cross: false + strip: strip - target: x86_64-unknown-linux-musl runner: ubuntu-latest artifact_name: electrs platform: x86_64-linux-musl use_cross: true + strip: strip - target: aarch64-unknown-linux-musl runner: ubuntu-latest artifact_name: electrs platform: aarch64-linux-musl use_cross: true + strip: aarch64-linux-gnu-strip runs-on: ${{ matrix.runner }} steps: @@ -93,8 +99,12 @@ jobs: echo "dir=target/release" >> $GITHUB_OUTPUT fi + - name: Install cross-arch strip tool + if: matrix.strip != 'strip' && runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu + - name: Strip binary - run: strip ${{ steps.binary.outputs.path }} + run: ${{ matrix.strip }} ${{ steps.binary.outputs.path }} - name: Create tarball env: From b65026dd7365fc02aa4253b6480f9aa5598cb673 Mon Sep 17 00:00:00 2001 From: Kohei Taniguchi Date: Mon, 13 Apr 2026 17:53:36 +0900 Subject: [PATCH 4/4] Fix review issues: pin cross v0.2.5, use strip=true in Cargo.toml, simplify version step - Remove test branch trigger from release workflow - Pin cross-rs Docker images to :0.2.5 (was :main) - Pin cross install to --tag v0.2.5 for reproducibility - Move strip to Cargo.toml (strip = true) and remove manual strip steps - Remove unreachable SHA fallback in Get version step (only tag trigger exists) Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/release.yml | 23 ++--------------------- Cargo.toml | 1 + Cross.toml | 4 ++-- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5bb50e6..b5cfa0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,8 +4,6 @@ on: push: tags: - 'v*' - branches: - - 'task-161-add-musl-static-build-for-release' env: CARGO_INCREMENTAL: 0 @@ -22,31 +20,26 @@ jobs: artifact_name: electrs platform: x86_64-linux-gnu use_cross: false - strip: strip - target: aarch64-unknown-linux-gnu runner: ubuntu-24.04-arm artifact_name: electrs platform: aarch64-linux-gnu use_cross: false - strip: strip - target: aarch64-apple-darwin runner: macos-14 artifact_name: electrs platform: aarch64-apple-darwin use_cross: false - strip: strip - target: x86_64-unknown-linux-musl runner: ubuntu-latest artifact_name: electrs platform: x86_64-linux-musl use_cross: true - strip: strip - target: aarch64-unknown-linux-musl runner: ubuntu-latest artifact_name: electrs platform: aarch64-linux-musl use_cross: true - strip: aarch64-linux-gnu-strip runs-on: ${{ matrix.runner }} steps: @@ -55,12 +48,7 @@ jobs: - name: Get version id: version - run: | - if [[ "$GITHUB_REF" == refs/tags/* ]]; then - echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - else - echo "tag=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT - fi + run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Install Rust uses: dtolnay/rust-toolchain@stable @@ -78,7 +66,7 @@ jobs: - name: Install cross if: matrix.use_cross - run: cargo install cross --git https://github.com/cross-rs/cross + run: cargo install cross --git https://github.com/cross-rs/cross --tag v0.2.5 - name: Build (cross) if: matrix.use_cross @@ -99,13 +87,6 @@ jobs: echo "dir=target/release" >> $GITHUB_OUTPUT fi - - name: Install cross-arch strip tool - if: matrix.strip != 'strip' && runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu - - - name: Strip binary - run: ${{ matrix.strip }} ${{ steps.binary.outputs.path }} - - name: Create tarball env: ASSET_NAME: electrs-${{ steps.version.outputs.tag }}-${{ matrix.platform }} diff --git a/Cargo.toml b/Cargo.toml index cf87590..5fa5587 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,3 +60,4 @@ features = ["force-cross"] lto = true panic = 'abort' codegen-units = 1 +strip = true diff --git a/Cross.toml b/Cross.toml index 1460c19..ba196bd 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,8 +1,8 @@ [target.x86_64-unknown-linux-musl] -image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:main" +image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:0.2.5" [target.aarch64-unknown-linux-musl] -image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:main" +image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:0.2.5" pre-build = [ # GMP's configure looks for tools named "aarch64-unknown-linux-musl-*" # but cross-rs provides them as "aarch64-linux-musl-*".