From 7b91c9ae4dbd9bda331027b38b6b5c64142eed8a Mon Sep 17 00:00:00 2001 From: Asmir Avdicevic Date: Tue, 21 Mar 2023 09:34:20 +0100 Subject: [PATCH] feat: release builds (#863) --- .github/workflows/ci.yml | 96 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 8 ++++ 2 files changed, 104 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f82664e3a..7e1f628c02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,6 +90,102 @@ jobs: command: test args: --all --target ${{ matrix.target }} + build_release: + name: Build release binaries + runs-on: ${{ matrix.runner }} + continue-on-error: false + needs: build_and_test_nix + if: ${{ always() && github.ref_name=='main' }} + strategy: + fail-fast: false + matrix: + name: [ubuntu-latest, ubuntu-arm-latest, macOS-latest, macOS-arm-latest] + rust: [stable] + experimental: [false] + include: + - name: ubuntu-arm-latest + os: ubuntu-latest + release-os: linux + release-arch: aarch64 + runner: [self-hosted, linux, ARM64] + - name: ubuntu-latest + os: ubuntu-latest + release-os: linux + release-arch: amd64 + runner: [self-hosted, linux, X64] + - name: macOS-latest + os: macOS-latest + release-os: darwin + release-arch: x86_64 + runner: [self-hosted, macOS, X64] + - name: macOS-arm-latest + os: macOS-latest + release-os: darwin + release-arch: aarch64 + runner: [self-hosted, macOS, ARM64] + # - os: windows-latest + # release-os: windows + # release-arch: amd64 + # runner: [windows-latest] + env: + RUST_BACKTRACE: full + RUSTV: ${{ matrix.rust }} + steps: + - name: Checkout + uses: actions/checkout@master + with: + submodules: recursive + + - name: Set build arch + run: | + echo "RELEASE_ARCH=${{ matrix.release-arch }}" >> $GITHUB_ENV + echo "RELEASE_OS=${{ matrix.release-os }}" >> $GITHUB_ENV + + - name: Install ${{ matrix.rust }} + run: | + rustup toolchain install ${{ matrix.rust }} + + - name: build release + run: | + cargo build --profile optimized-release + + - name: Setup awscli on linux + if: matrix.name == 'ubuntu-latest' + run: | + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + sudo ./aws/install --update + + - name: Setup awscli on linux + if: matrix.name == 'ubuntu-arm-latest' + run: | + curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + sudo ./aws/install --update + + - name: Setup awscli on mac + if: matrix.os == 'macos-latest' + run: | + curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" + sudo installer -pkg AWSCLIV2.pkg -target / + + - name: Set aws credentials + if: matrix.os != 'windows-latest' + run: | + echo "AWS_ACCESS_KEY_ID=${{secrets.S3_ACCESS_KEY_ID}}" >> $GITHUB_ENV + echo "AWS_SECRET_ACCESS_KEY=${{secrets.S3_ACCESS_KEY}}" >> $GITHUB_ENV + echo "AWS_DEFAULT_REGION=us-west-2" >> $GITHUB_ENV + + - name: push release + if: matrix.os != 'windows-latest' + run: | + aws s3 cp ./target/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress + + - name: push release latest + if: matrix.os != 'windows-latest' + run: | + aws s3 cp ./target/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress + cross: name: Cross compile runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 036b4ca075..e90b63ba6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,3 +67,11 @@ test = [] [[bin]] name = "iroh" required-features = ["cli"] + +[profile.optimized-release] +inherits = 'release' +lto = true +debug-assertions = false +opt-level = 3 +panic = 'abort' +incremental = false \ No newline at end of file