Skip to content

Commit

Permalink
Add github actions to compile a release for all platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed Oct 18, 2021
1 parent b2fb472 commit e925ebd
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Rust

on:
push:
tags:
- "v*.*.*"

env:
CARGO_TERM_COLOR: always

jobs:
release-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build release
run:
cargo build --release
- uses: softprops/action-gh-release@v1
with:
body: This release and its artifacts were built with a GitHub action
files: |
target/release/rqbit.exe
cross-compile-on-macos:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- name: install linux cross compiler
run:
brew tap messense/macos-cross-toolchains &&
brew install x86_64-unknown-linux-gnu

- name: Build release linux x86_64 binary
run:
rustup target install x86_64-unknown-linux-gnu &&
make release-linux &&
mv target/x86_64-unknown-linux-gnu/release/rqbit target/release/rqbit-linux-static-x86_64

- name: Build release OSX universal binary
run:
rustup target install aarch64-apple-darwin &&
cargo build --release &&
cargo build --release --target aarch64-apple-darwin &&
lipo ./target/release/rqbit ./target/aarch64-apple-darwin/release/rqbit -create -output ./target/release/rqbit-osx-universal

- uses: softprops/action-gh-release@v1
with:
body: This release and its artifacts were built with a GitHub action
files: |
target/release/rqbit-osx-universal
target/release/rqbit-linux-static-x86_64
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,29 @@ release-windows:
# brew install mingw-w64
cargo build --target x86_64-pc-windows-gnu --release

target/openssl-linux/lib/libssl.a:
export OPENSSL_ROOT=$(PWD)/target/openssl-linux/ && \
mkdir -p "$${OPENSSL_ROOT}"/src && \
cd "$${OPENSSL_ROOT}"/src/ && \
curl -LO https://www.openssl.org/source/openssl-3.0.0.tar.gz && \
tar xf openssl-3.0.0.tar.gz && \
cd openssl-3.0.0 && \
./Configure linux-generic64 --prefix="$${OPENSSL_ROOT}" --openssldir="$${OPENSSL_ROOT}" no-shared --cross-compile-prefix=x86_64-unknown-linux-gnu- && \
make -j && \
make install_sw

@PHONY: release-linux
release-linux:
release-linux: target/openssl-linux/lib/libssl.a
# prereqs:
# brew tap messense/macos-cross-toolchains
# brew install x86_64-unknown-linux-gnu
# cross-compile openssl with "no-shared", e.g.
# ./Configure linux-generic64 --prefix=$HOME/projects/2021-18-linux-cross/prefix/ --openssldir=$HOME/projects/2021-18-linux-cross/prefix/ --cross-compile-prefix=x86_64-unknown-linux-gnu- no-shared
# ./Configure linux-generic64 --prefix=$(PWD)/target/openssl-linux/ --openssldir=$(PWD)/target/openssl-linux/ --cross-compile-prefix=x86_64-unknown-linux-gnu- no-shared
CC_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-gcc \
CXX_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-g++ \
AR_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-ar \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc \
OPENSSL_DIR=/Users/igor/projects/2021-18-linux-cross/prefix \
OPENSSL_DIR=$(PWD)/target/openssl-linux/ \
cargo build --release --target=x86_64-unknown-linux-gnu


Expand Down

0 comments on commit e925ebd

Please sign in to comment.