diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bd809d..b5cfa0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,20 +12,34 @@ env: jobs: build: strategy: + fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu 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-latest + artifact_name: electrs + platform: aarch64-linux-musl + use_cross: true runs-on: ${{ matrix.runner }} steps: @@ -50,17 +64,34 @@ 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 --tag v0.2.5 + + - 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: Strip binary - run: strip target/release/${{ matrix.artifact_name }} + - 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: 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 +99,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 +107,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 +115,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 +134,7 @@ jobs: run: cargo publish release: + if: startsWith(github.ref, 'refs/tags/') needs: build runs-on: ubuntu-latest permissions: @@ -122,4 +155,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..5fa5587 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,7 +52,12 @@ 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' codegen-units = 1 +strip = true diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..ba196bd --- /dev/null +++ b/Cross.toml @@ -0,0 +1,11 @@ +[target.x86_64-unknown-linux-musl] +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: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-*". + # 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'", +]