diff --git a/.github/workflows/calimero_node_linux.yml b/.github/workflows/calimero_node_linux.yml deleted file mode 100644 index be76117bf..000000000 --- a/.github/workflows/calimero_node_linux.yml +++ /dev/null @@ -1,203 +0,0 @@ -name: Build and Upload Binary for Linux - -on: - push: - branches: - - '**' - pull_request: - types: [closed] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] - - outputs: - artifact_path: ${{ steps.compress.outputs.artifact_path }} - target: ${{ matrix.target }} - version: ${{ steps.extract_version.outputs.version }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup rust toolchain - run: rustup toolchain install stable --profile minimal - - - name: Setup rust cache - uses: Swatinem/rust-cache@v2 - with: - key: ${{ runner.os }}-calimero-node-${{ matrix.target }} - - - name: Install target for ${{ matrix.target }} - run: rustup target add ${{ matrix.target }} - - - name: Install dependencies for cross-compilation - run: | - sudo apt-get update - sudo apt-get install -y \ - gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ - libssl-dev pkg-config - - - name: Download and set up OpenSSL for cross-compilation - if: matrix.target == 'aarch64-unknown-linux-gnu' - run: | - wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz - tar -xzf openssl-1.1.1k.tar.gz - cd openssl-1.1.1k - ./Configure linux-aarch64 --prefix=$HOME/openssl-aarch64 --cross-compile-prefix=aarch64-linux-gnu- - make -j$(nproc) - make install_sw - cd .. - echo "OPENSSL_DIR=$HOME/openssl-aarch64" >> $GITHUB_ENV - echo "PKG_CONFIG_PATH=$HOME/openssl-aarch64/lib/pkgconfig" >> $GITHUB_ENV - echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV - echo "PKG_CONFIG_SYSROOT_DIR=/" >> $GITHUB_ENV - - - name: Build the crate for AArch64 - if: matrix.target == 'aarch64-unknown-linux-gnu' - env: - OPENSSL_DIR: ${{ env.OPENSSL_DIR }} - PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }} - PKG_CONFIG_ALLOW_CROSS: ${{ env.PKG_CONFIG_ALLOW_CROSS }} - PKG_CONFIG_SYSROOT_DIR: ${{ env.PKG_CONFIG_SYSROOT_DIR }} - CC: aarch64-linux-gnu-gcc - CXX: aarch64-linux-gnu-g++ - AR: aarch64-linux-gnu-ar - RANLIB: aarch64-linux-gnu-ranlib - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - run: cargo build -p calimero-node --release --target ${{ matrix.target }} - - - name: Build the crate for x86_64 - if: matrix.target == 'x86_64-unknown-linux-gnu' - run: cargo build -p calimero-node --release --target ${{ matrix.target }} - - - name: Extract version - id: extract_version - run: | - VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "calimero-node") | .version') - echo "version=$VERSION" >> $GITHUB_OUTPUT - - - name: Compress artifact using gzip - id: compress - run: | - tar -czf calimero-node_${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release calimero-node - echo "artifact_path=calimero-node_${{ matrix.target }}.tar.gz" >> $GITHUB_OUTPUT - echo "target=${{ matrix.target }}" >> $GITHUB_OUTPUT - - - name: Cache build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - upload_branch_artifact: - runs-on: ubuntu-latest - needs: build - strategy: - matrix: - target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] - if: ${{ github.ref != 'refs/heads/master' }} - - steps: - - name: Restore build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - - name: Sanitize ref name - id: sanitize - run: | - sanitized_ref_name=$(echo "${GITHUB_REF_NAME}" | sed 's/[^a-zA-Z0-9_-]/-/g; s/^-*//; s/-*$//') - echo "sanitized_ref_name=${sanitized_ref_name}" >> $GITHUB_OUTPUT - - - name: Upload binary as artifact - uses: actions/upload-artifact@v4 - with: - name: calimero-node_${{ steps.sanitize.outputs.sanitized_ref_name }}_${{ matrix.target }}.tar.gz - path: calimero-node_${{ matrix.target }}.tar.gz - retention-days: 2 - - create_release: - runs-on: ubuntu-latest - needs: build - outputs: - release_exists: ${{ steps.check_release.outputs.release_exists }} - version: ${{ needs.build.outputs.version }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check if release exists - id: check_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - if gh release view "v$VERSION" >/dev/null 2>&1; then - echo "release_exists=true" >> $GITHUB_OUTPUT - else - echo "release_exists=false" >> $GITHUB_OUTPUT - fi - - - name: Create release if it does not exist - if: steps.check_release.outputs.release_exists == 'false' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - gh release create "v$VERSION" --title "Release v$VERSION" --notes "Release for version $VERSION" - - upload_release_artifact: - runs-on: ubuntu-latest - needs: [build, create_release] - strategy: - matrix: - target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] - if: ${{ github.ref == 'refs/heads/master' || (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master') }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Restore build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - - name: Check if artifact exists in release - id: check_artifact - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - TARGET=${{ matrix.target }} - ARTIFACT_NAME="calimero-node_${TARGET}.tar.gz" - ASSET_ID=$(gh api \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - /repos/${{ github.repository }}/releases/tags/v$VERSION \ - | jq -r ".assets[] | select(.name == \"$ARTIFACT_NAME\") | .id") - if [[ -n "$ASSET_ID" ]]; then - echo "exists=true" >> $GITHUB_OUTPUT - else - echo "exists=false" >> $GITHUB_OUTPUT - fi - - - name: Upload artifact to release - if: steps.check_artifact.outputs.exists == 'false' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - TARGET=${{ matrix.target }} - gh release upload "v$VERSION" calimero-node_${TARGET}.tar.gz diff --git a/.github/workflows/calimero_node_macos.yml b/.github/workflows/calimero_node_macos.yml deleted file mode 100644 index 453d62611..000000000 --- a/.github/workflows/calimero_node_macos.yml +++ /dev/null @@ -1,168 +0,0 @@ -name: Build and Upload Binary for MacOS - -on: - push: - branches: - - '**' - pull_request: - types: [closed] - -jobs: - build: - runs-on: macos-latest - strategy: - matrix: - target: [x86_64-apple-darwin, aarch64-apple-darwin] - - outputs: - artifact_path: ${{ steps.compress.outputs.artifact_path }} - target: ${{ matrix.target }} - version: ${{ steps.extract_version.outputs.version }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup rust toolchain - run: rustup toolchain install stable --profile minimal - - - name: Setup rust cache - uses: Swatinem/rust-cache@v2 - with: - key: ${{ runner.os }}-calimero-node-${{ matrix.target }} - - - name: Install target for ${{ matrix.target }} - run: rustup target add ${{ matrix.target }} - - - name: Build the crate - run: cargo build -p calimero-node --release --target ${{ matrix.target }} - - - name: Extract version - id: extract_version - run: | - VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "calimero-node") | .version') - echo "version=$VERSION" >> $GITHUB_OUTPUT - - - name: Compress artifact using gzip - id: compress - run: | - tar -czf calimero-node_${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release calimero-node - echo "artifact_path=calimero-node_${{ matrix.target }}.tar.gz" >> $GITHUB_OUTPUT - echo "target=${{ matrix.target }}" >> $GITHUB_OUTPUT - - - name: Cache build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - upload_branch_artifact: - runs-on: ubuntu-latest - needs: build - strategy: - matrix: - target: [x86_64-apple-darwin, aarch64-apple-darwin] - if: ${{ github.ref != 'refs/heads/master' }} - - steps: - - name: Restore build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - - name: Sanitize ref name - id: sanitize - run: | - sanitized_ref_name=$(echo "${GITHUB_REF_NAME}" | sed 's/[^a-zA-Z0-9_-]/-/g; s/^-*//; s/-*$//') - echo "sanitized_ref_name=${sanitized_ref_name}" >> $GITHUB_OUTPUT - - - name: Upload binary as artifact - uses: actions/upload-artifact@v4 - with: - name: calimero-node_${{ steps.sanitize.outputs.sanitized_ref_name }}_${{ matrix.target }}.tar.gz - path: calimero-node_${{ matrix.target }}.tar.gz - retention-days: 2 - - create_release: - runs-on: ubuntu-latest - needs: build - strategy: - matrix: - target: [x86_64-apple-darwin, aarch64-apple-darwin] - if: ${{ github.ref == 'refs/heads/master' || (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master') }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check if release exists - id: check_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if gh release view "v${{ github.event.inputs.version }}" >/dev/null 2>&1; then - echo "release_exists=true" >> $GITHUB_ENV - else - echo "release_exists=false" >> $GITHUB_ENV - fi - - - name: Create release if it does not exist - if: env.release_exists == 'false' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - gh release create "v$VERSION" --title "Release v$VERSION" --notes "Release for version $VERSION" - - upload_release_artifact: - runs-on: ubuntu-latest - needs: [build, create_release] - strategy: - matrix: - target: [x86_64-apple-darwin, aarch64-apple-darwin] - if: ${{ github.ref == 'refs/heads/master' || (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master') }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Restore build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - - name: Check if artifact exists in release - id: check_artifact - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - TARGET=${{ matrix.target }} - ARTIFACT_NAME="calimero-node_${TARGET}.tar.gz" - ASSET_ID=$(gh api \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - /repos/${{ github.repository }}/releases/tags/v$VERSION \ - | jq -r ".assets[] | select(.name == \"$ARTIFACT_NAME\") | .id") - echo "ASSET_ID=$ASSET_ID" - if [[ -n "$ASSET_ID" ]]; then - echo "exists=true" >> $GITHUB_OUTPUT - else - echo "exists=false" >> $GITHUB_OUTPUT - fi - - - name: Upload artifact to release - if: steps.check_artifact.outputs.exists == 'false' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.build.outputs.version }} - TARGET=${{ matrix.target }} - gh release upload "v$VERSION" calimero-node_${TARGET}.tar.gz \ No newline at end of file diff --git a/.github/workflows/calimero_node_win.yml b/.github/workflows/calimero_node_win.yml index 3bb0d9042..c7e3d3a09 100644 --- a/.github/workflows/calimero_node_win.yml +++ b/.github/workflows/calimero_node_win.yml @@ -8,111 +8,127 @@ on: types: [closed] jobs: - release: - name: Release - ${{ matrix.platform.os_name }} + test: + name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }} + runs-on: ${{ matrix.platform.os }} strategy: + fail-fast: false matrix: platform: + # Platforms that don't work: + # + # - sparc64-unknown-linux-gnu - cannot compile openssl-sys + # - x86_64-unknown-illumos - weird error compiling openssl - "bin/sh: 1: granlib: not found" + - os_name: FreeBSD-x86_64 os: ubuntu-20.04 target: x86_64-unknown-freebsd bin: calimero-node name: calimero-node-FreeBSD-x86_64.tar.gz - cross: true - cargo_command: ./cross - + skip_tests: true - os_name: Linux-x86_64 os: ubuntu-20.04 target: x86_64-unknown-linux-musl bin: calimero-node name: calimero-node-Linux-x86_64-musl.tar.gz - cross: false - cargo_command: cargo - + - os_name: Linux-aarch64 + os: ubuntu-20.04 + target: aarch64-unknown-linux-musl + bin: calimero-node + name: calimero-node-Linux-aarch64-musl.tar.gz + - os_name: Linux-arm + os: ubuntu-20.04 + target: arm-unknown-linux-musleabi + bin: calimero-node + name: calimero-node-Linux-arm-musl.tar.gz + - os_name: Linux-i686 + os: ubuntu-20.04 + target: i686-unknown-linux-musl + bin: calimero-node + name: calimero-node-Linux-i686-musl.tar.gz + skip_tests: true + - os_name: Linux-powerpc + os: ubuntu-20.04 + target: powerpc-unknown-linux-gnu + bin: calimero-node + name: calimero-node-Linux-powerpc-gnu.tar.gz + skip_tests: true + - os_name: Linux-powerpc64 + os: ubuntu-20.04 + target: powerpc64-unknown-linux-gnu + bin: calimero-node + name: calimero-node-Linux-powerpc64-gnu.tar.gz + skip_tests: true + - os_name: Linux-powerpc64le + os: ubuntu-20.04 + target: powerpc64le-unknown-linux-gnu + bin: calimero-node + name: calimero-node-Linux-powerpc64le.tar.gz + skip_tests: true + - os_name: Linux-riscv64 + os: ubuntu-20.04 + target: riscv64gc-unknown-linux-gnu + bin: calimero-node + name: calimero-node-Linux-riscv64gc-gnu.tar.gz + - os_name: Linux-s390x + os: ubuntu-20.04 + target: s390x-unknown-linux-gnu + bin: calimero-node + name: calimero-node-Linux-s390x-gnu.tar.gz + skip_tests: true + - os_name: NetBSD-x86_64 + os: ubuntu-20.04 + target: x86_64-unknown-netbsd + bin: calimero-node + name: calimero-node-NetBSD-x86_64.tar.gz + skip_tests: true - os_name: Windows-aarch64 os: windows-latest target: aarch64-pc-windows-msvc bin: calimero-node.exe name: calimero-node-Windows-aarch64.zip - cross: false - cargo_command: cargo - + skip_tests: true + - os_name: Windows-i686 + os: windows-latest + target: i686-pc-windows-msvc + bin: calimero-node.exe + name: calimero-node-Windows-i686.zip + skip_tests: true - os_name: Windows-x86_64 os: windows-latest target: x86_64-pc-windows-msvc bin: calimero-node.exe name: calimero-node-Windows-x86_64.zip - cross: false - cargo_command: cargo - - os_name: macOS-x86_64 os: macOS-latest target: x86_64-apple-darwin bin: calimero-node name: calimero-node-Darwin-x86_64.tar.gz - cross: false - cargo_command: cargo - - - os_name: macOS-x86_64 + - os_name: macOS-aarch64 os: macOS-latest target: aarch64-apple-darwin bin: calimero-node name: calimero-node-Darwin-aarch64.tar.gz - cross: false - cargo_command: cargo - - runs-on: ${{ matrix.platform.os }} + skip_tests: true + toolchain: + - stable steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install toolchain if not cross-compiling - uses: dtolnay/rust-toolchain@stable + - uses: actions/checkout@v4 + - name: Cache cargo & target directories + uses: Swatinem/rust-cache@v2 with: - targets: ${{ matrix.platform.target }} - if: ${{ !matrix.platform.cross }} - + key: "v2" - name: Install musl-tools on Linux run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools - if: contains(matrix.platform.os, 'ubuntu') && !matrix.platform.cross - - - name: Install cross if cross-compiling (*nix) - id: cross-nix - shell: bash - run: | - set -e - export TARGET="$HOME/bin" - mkdir -p "$TARGET" - ./bootstrap/bootstrap-ubi.sh - "$HOME/bin/ubi" --project cross-rs/cross --matching musl --in . - if: matrix.platform.cross && !contains(matrix.platform.os, 'windows') - - - name: Install cross if cross-compiling (Windows) - id: cross-windows - shell: powershell - run: | - .\bootstrap\bootstrap-ubi.ps1 - .\ubi --project cross-rs/cross --in . - if: matrix.platform.cross && contains(matrix.platform.os, 'windows') - - - name: Build binary (*nix) - shell: bash - run: | - ${{ matrix.platform.cargo_command }} build -p calimero-node --locked --release --target ${{ matrix.platform.target }} - if: ${{ !contains(matrix.platform.os, 'windows') }} - - - name: Build binary (Windows) - shell: powershell - run: | - & ${{ matrix.platform.cargo_command }} build -p calimero-node --locked --release --target ${{ matrix.platform.target }} - if: contains(matrix.platform.os, 'windows') - - - name: Strip binary - shell: bash - run: | - strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} - if: ${{ !(matrix.platform.cross || matrix.platform.target == 'aarch64-pc-windows-msvc') }} - + if: contains(matrix.platform.name, 'musl') + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0 + with: + command: "build" + target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.toolchain }} + args: "-p calimero-node --locked --release" + strip: true - name: Package as archive shell: bash run: | @@ -123,9 +139,8 @@ jobs: tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} fi cd - - - name: Publish release artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: calimero-node-${{ matrix.platform.os_name }} - path: "calimero-node*" + path: "calimero-node-*"