Merge branch 'master' into release #155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- release | |
jobs: | |
publish-rust-sdk: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
max-parallel: 1 | |
matrix: | |
package: | |
- name: longport-proto | |
registryName: longport-proto | |
path: rust/crates/proto | |
- name: longport-httpcli | |
registryName: longport-httpcli | |
path: rust/crates/httpclient | |
- name: longport-wscli | |
registryName: longport-wscli | |
path: rust/crates/wsclient | |
- name: longport-candlesticks | |
registryName: longport-candlesticks | |
path: rust/crates/candlesticks | |
- name: longport | |
registryName: longport | |
path: rust | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: get version | |
working-directory: ${{ matrix.package.path }} | |
run: echo PACKAGE_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV | |
- name: check published version | |
run: echo PUBLISHED_VERSION=$(cargo search ${{ matrix.package.registryName }} --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -) >> $GITHUB_ENV | |
- name: cargo login | |
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION | |
run: cargo login ${{ secrets.CRATES_TOKEN }} | |
- name: cargo package | |
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION | |
working-directory: ${{ matrix.package.path }} | |
run: | | |
cargo package | |
echo "We will publish:" $PACKAGE_VERSION | |
echo "This is current latest:" $PUBLISHED_VERSION | |
- name: Publish ${{ matrix.package.name }} | |
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION | |
working-directory: ${{ matrix.package.path }} | |
run: | | |
echo "# Cargo Publish" | |
cargo publish --no-verify | |
build-python-sdk-macos: | |
runs-on: macos-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: x64 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
default: true | |
- name: Build wheels - x86_64 | |
uses: messense/maturin-action@v1 | |
with: | |
target: x86_64 | |
args: -i python --release --out dist -m python/Cargo.toml | |
- name: Install built wheel - x86_64 | |
run: | | |
pip install longport --no-index --find-links dist --force-reinstall | |
- name: Build wheels - universal2 | |
if: ${{ fromJSON(matrix.python-version) >= 3.8 }} | |
uses: messense/maturin-action@v1 | |
with: | |
args: -i python --release --universal2 --out dist --no-sdist -m python/Cargo.toml | |
- name: Install built wheel - universal2 | |
if: ${{ fromJSON(matrix.python-version) >= 3.8 }} | |
run: | | |
pip install longport --no-index --find-links dist --force-reinstall | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
build-python-sdk-windows: | |
runs-on: windows-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
target: [x64, x86] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.target }} | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
default: true | |
- name: Build wheels | |
uses: messense/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: -i python --release --out dist --no-sdist -m python/Cargo.toml | |
- name: Install built wheel | |
run: | | |
pip install longport --no-index --find-links dist --force-reinstall | |
python -c "import longport" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
build-python-sdk-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
target: [x86_64, i686] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build wheels | |
uses: messense/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: -i ${{ matrix.python-version }} --release --out dist --no-sdist -m python/Cargo.toml | |
- name: Install built wheel | |
if: matrix.target == 'x86_64' | |
run: | | |
pip install longport --no-index --find-links dist --force-reinstall | |
python -c "import longport" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
build-python-sdk-linux-cross: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
target: [aarch64] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Build wheels | |
uses: messense/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: 2_28 | |
args: -i ${{ matrix.python-version }} --release --out dist --no-sdist -m python/Cargo.toml | |
- uses: uraimo/[email protected] | |
if: matrix.target != 'ppc64' | |
name: Install built wheel | |
with: | |
arch: ${{ matrix.target }} | |
distro: ubuntu20.04 | |
githubToken: ${{ github.token }} | |
dockerRunArgs: | | |
--volume "${PWD}/dist:/artifacts" | |
install: | | |
apt-get update | |
apt-get install -y --no-install-recommends python3 python3-venv software-properties-common | |
add-apt-repository ppa:deadsnakes/ppa | |
apt-get update | |
apt-get install -y curl python3.7-venv python3.8-venv python3.9-venv python3.10-venv python3.11-venv | |
run: | | |
ls -lrth /artifacts | |
PYTHON=python${{ matrix.python-version }} | |
$PYTHON -m venv venv | |
venv/bin/pip install -U pip | |
venv/bin/pip install longport --no-index --find-links /artifacts --force-reinstall | |
venv/bin/python -c 'import longport' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
publish-python-sdk: | |
runs-on: ubuntu-latest | |
needs: | |
- build-python-sdk-macos | |
- build-python-sdk-windows | |
- build-python-sdk-linux | |
- build-python-sdk-linux-cross | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: wheels | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- name: Publish to PyPi | |
env: | |
TWINE_USERNAME: Sunli | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
pip install --upgrade twine | |
twine upload --skip-existing * | |
build-nodejs-sdk: | |
strategy: | |
fail-fast: true | |
matrix: | |
settings: | |
- host: macos-latest | |
architecture: x64 | |
build: | | |
npm run build | |
strip -x *.node | |
- host: windows-latest | |
build: npm run build | |
architecture: x64 | |
- host: ubuntu-latest | |
build: | | |
npm run build | |
strip *.node | |
- host: macos-latest | |
target: aarch64-apple-darwin | |
build: | | |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; | |
export CC=$(xcrun -f clang); | |
export CXX=$(xcrun -f clang++); | |
SYSROOT=$(xcrun --sdk macosx --show-sdk-path); | |
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; | |
yarn build --target aarch64-apple-darwin | |
strip -x *.node | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
architecture: ${{ matrix.settings.architecture }} | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
target: ${{ matrix.settings.target }} | |
- name: Check with clippy | |
run: cargo clippy -p longport-nodejs --all-features | |
- name: Test | |
run: cargo test -p longport-nodejs --all-features | |
- name: Install napi-rs/cli | |
run: npm install -g @napi-rs/cli | |
- name: Build | |
working-directory: nodejs | |
run: ${{ matrix.settings.build }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bindings | |
path: nodejs/longport.*.node | |
publish-nodejs-sdk: | |
runs-on: ubuntu-latest | |
needs: | |
- build-nodejs-sdk | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update versions | |
run: node ./.github/misc/update_jssdk_version.mjs $(sed -nE 's/^\s*version = "(.*?)"/\1/p' nodejs/Cargo.toml) | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
- name: Install napi-rs/cli | |
run: npm install -g @napi-rs/cli | |
- name: Download all artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: bindings | |
path: ./nodejs/artifacts | |
- name: Move artifacts | |
run: napi artifacts | |
working-directory: ./nodejs | |
- name: List packages | |
run: ls -R ./npm | |
shell: bash | |
working-directory: ./nodejs | |
- name: Publish | |
run: | | |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
npm publish --access public | |
working-directory: ./nodejs | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
build-java-jni: | |
strategy: | |
fail-fast: true | |
matrix: | |
settings: | |
- host: ubuntu-latest | |
container: centos:7 | |
lib_prefix: "lib" | |
lib_suffix: ".so" | |
target: x86_64-unknown-linux-gnu | |
- host: ubuntu-latest | |
lib_prefix: "lib" | |
lib_suffix: ".so" | |
target: aarch64-unknown-linux-gnu | |
- host: windows-latest | |
lib_suffix: ".dll" | |
target: x86_64-pc-windows-msvc | |
- host: macos-latest | |
lib_prefix: "lib" | |
lib_suffix: ".dylib" | |
target: x86_64-apple-darwin | |
- host: macos-latest | |
lib_prefix: "lib" | |
lib_suffix: ".dylib" | |
target: aarch64-apple-darwin | |
runs-on: ${{ matrix.settings.host }} | |
container: ${{ matrix.settings.container }} | |
steps: | |
- name: Install Git & Gcc | |
if: ${{ contains(matrix.settings.container, 'centos') }} | |
run: | | |
yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm | |
yum install -y git gcc | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
target: ${{ matrix.settings.target }} | |
- name: Build | |
if: ${{ matrix.settings.target != 'aarch64-unknown-linux-gnu' }} | |
run: | | |
cargo build -p longport-java --release --target ${{ matrix.settings.target }} | |
mv target/${{ matrix.settings.target }}/release/${{ matrix.settings.lib_prefix }}longport_java${{ matrix.settings.lib_suffix }} longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }} | |
- name: Build with Cross | |
if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }} | |
run: | | |
cargo install cross | |
cross build -p longport-java --release --target ${{ matrix.settings.target }} | |
mv target/${{ matrix.settings.target }}/release/${{ matrix.settings.lib_prefix }}longport_java${{ matrix.settings.lib_suffix }} longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: jnis | |
path: longport_java-${{ matrix.settings.target }}${{ matrix.settings.lib_suffix }} | |
publish-java-sdk: | |
runs-on: ubuntu-latest | |
needs: build-java-jni | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
- name: Download all artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: jnis | |
path: ./java/jnis | |
- name: Copy jnis | |
working-directory: java | |
run: | | |
mkdir -p javasrc/target/natives/linux_64 | |
mkdir -p javasrc/target/natives/linux_arm64 | |
mkdir -p javasrc/target/natives/windows_64 | |
mkdir -p javasrc/target/natives/osx_64 | |
mkdir -p javasrc/target/natives/osx_arm64 | |
mv jnis/longport_java-x86_64-unknown-linux-gnu.so javasrc/target/natives/linux_64/liblongport_java.so | |
mv jnis/longport_java-aarch64-unknown-linux-gnu.so javasrc/target/natives/linux_arm64/liblongport_java.so | |
mv jnis/longport_java-x86_64-pc-windows-msvc.dll javasrc/target/natives/windows_64/longport_java.dll | |
mv jnis/longport_java-x86_64-apple-darwin.dylib javasrc/target/natives/osx_64/liblongport_java.dylib | |
mv jnis/longport_java-aarch64-apple-darwin.dylib javasrc/target/natives/osx_arm64/liblongport_java.dylib | |
- name: Get version | |
working-directory: java | |
run: echo PACKAGE_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV | |
- name: Update version | |
working-directory: java/javasrc | |
run: mvn versions:set -DnewVersion=${PACKAGE_VERSION} | |
- name: Publish maven package | |
uses: samuelmeuli/action-maven-publish@v1 | |
with: | |
directory: java/javasrc | |
maven_profiles: release | |
maven_goals_phases: deploy | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
nexus_username: ${{ secrets.OSSRH_USERNAME }} | |
nexus_password: ${{ secrets.OSSRH_PASSWORD }} | |
copy-cpp-headers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: include | |
path: c/csrc/include | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: include | |
path: cpp/include | |
build-cpp-sdk: | |
needs: | |
- copy-cpp-headers | |
strategy: | |
fail-fast: true | |
matrix: | |
settings: | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
platform: x86_64_linux | |
dylib_ext: so | |
- host: windows-latest | |
target: x86_64-pc-windows-msvc | |
platform: x86_64_windows | |
- host: macos-latest | |
target: x86_64-apple-darwin | |
platform: x86_64_macos | |
dylib_ext: dylib | |
- host: macos-latest | |
target: aarch64-apple-darwin | |
platform: aarch64_macos | |
dylib_ext: dylib | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install MSBuild | |
if: ${{ matrix.settings.host == 'windows-latest' }} | |
uses: microsoft/[email protected] | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt, clippy | |
target: ${{ matrix.settings.target }} | |
- name: Get CMake | |
uses: lukka/get-cmake@latest | |
- name: Install cargo make | |
run: cargo install cargo-make | |
- name: Build | |
if: ${{ matrix.settings.target != 'aarch64-apple-darwin' }} | |
run: | | |
cargo make cmake-release | |
cargo make c-release | |
cargo make cpp-release | |
- name: Build | |
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }} | |
run: | | |
cargo make cmake-release-macos-aarch64 | |
cargo make cpp-release | |
- name: Copy files | |
if: ${{ matrix.settings.host == 'windows-latest' }} | |
run: | | |
md dist\lib\${{ matrix.settings.platform }} | |
copy cmake.build\C\Release\longport_c.dll dist\lib\${{ matrix.settings.platform }} | |
copy cmake.build\C\Release\longport_c.dll.lib dist\lib\${{ matrix.settings.platform }}\longport_c.lib | |
copy cmake.build\Release\longport_cpp.dll dist\lib\${{ matrix.settings.platform }} | |
copy cmake.build\cpp\Release\longport_cpp.lib dist\lib\${{ matrix.settings.platform }} | |
- name: Copy files | |
if: ${{ matrix.settings.host != 'windows-latest' }} | |
run: | | |
mkdir -p dist/lib/${{ matrix.settings.platform }} | |
cp cmake.build/c/liblongport_c.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }} | |
cp cmake.build/liblongport_cpp.${{ matrix.settings.dylib_ext }} dist/lib/${{ matrix.settings.platform }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: libs | |
path: dist/lib | |
publish-cpp-sdk: | |
needs: | |
- build-cpp-sdk | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download includes | |
uses: actions/download-artifact@v2 | |
with: | |
name: libs | |
path: ./sdk/libs | |
- name: Download includes | |
uses: actions/download-artifact@v2 | |
with: | |
name: include | |
path: ./sdk/include | |
- name: Get Version | |
run: echo SDK_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' c/Cargo.toml) >> $GITHUB_ENV | |
- name: Package | |
run: tar czvf openapi-cpp-sdk-$SDK_VERSION.tar.gz ./sdk | |
- name: Upload SDK to BJ | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.FE_S3_OPEN_STATIC_PROD_BJ_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.FE_S3_OPEN_STATIC_PROD_BJ_ACCESS_KEY_SECRET }} | |
run: | | |
aws --region=${{ secrets.PROD_BJ_AWS_DEFAULT_REGION }} s3 cp openapi-cpp-sdk-$SDK_VERSION.tar.gz s3://${{ secrets.FE_S3_OPEN_STATIC_PROD_BJ_BUCKET }}/openapi-sdk/ --cache-control max-age=31536000 | |
- name: Upload SDK to HK | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.FE_S3_OPEN_STATIC_PROD_HK_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.FE_S3_OPEN_STATIC_PROD_HK_ACCESS_KEY_SECRET }} | |
run: | | |
aws --region=${{ secrets.PROD_HK_AWS_DEFAULT_REGION }} s3 cp openapi-cpp-sdk-$SDK_VERSION.tar.gz s3://${{ secrets.FE_S3_OPEN_STATIC_PROD_HK_BUCKET }}/openapi-sdk/ --cache-control max-age=31536000 |