296 lines
7.9 KiB
YAML
296 lines
7.9 KiB
YAML
name: Build Binaries
|
|
|
|
on:
|
|
# Runs on pushes targeting the default branch
|
|
push:
|
|
|
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
concurrency:
|
|
group: "pages"
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
# Build job
|
|
build:
|
|
name: Build & Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Cargo Build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Cargo Test
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
|
|
buildPy:
|
|
name: Build Python
|
|
runs-on: ubuntu-latest
|
|
needs: [ build ] # for ignoring bad builds
|
|
steps:
|
|
- uses: actions/checkout@v4 # get source
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install Python 3
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ env.python-version }}
|
|
|
|
- name: Install Maturin
|
|
run: sudo apt update && sudo apt install -y python3-maturin
|
|
|
|
- name: Build Python
|
|
working-directory: ./pyfinlib
|
|
run: maturin build
|
|
|
|
buildNET:
|
|
name: Build .NET
|
|
runs-on: ubuntu-latest
|
|
needs: [ build ] # for ignoring bad builds
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Cargo Build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Setup .NET Core SDK 9.0.x
|
|
uses: actions/setup-dotnet@v3.0.3
|
|
with:
|
|
dotnet-version: 9.0.x
|
|
|
|
- name: Install Dependencies
|
|
working-directory: ./FinLib.NET
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
working-directory: ./FinLib.NET
|
|
run: dotnet build --configuration Debug --no-restore
|
|
|
|
- name: Test
|
|
working-directory: ./FinLib.NET
|
|
run: dotnet test --no-restore
|
|
|
|
publishNET:
|
|
name: Publish .NET
|
|
runs-on: ubuntu-latest
|
|
needs: [ buildNET ] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Cargo Build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Setup .NET Core SDK 9.0.x
|
|
uses: actions/setup-dotnet@v3.0.3
|
|
with:
|
|
dotnet-version: 9.0.x
|
|
|
|
- name: Install Dependencies
|
|
working-directory: ./FinLib.NET
|
|
run: dotnet restore
|
|
|
|
- name: Pack
|
|
working-directory: ./FinLib.NET/FinLib
|
|
run: dotnet pack -p:PackageVersion=$(pushd ../../finlib > /dev/null && cargo pkgid | awk -F '[,#]' '{print $2}' && popd > /dev/null) -P:PackageId="Sarsoo.FinLib.NET"
|
|
|
|
- name: Push
|
|
working-directory: ./FinLib.NET/FinLib
|
|
run: dotnet nuget push ./bin/Release/Sarsoo.FinLib.NET.$(pushd ../../finlib > /dev/null && cargo pkgid | awk -F '[,#]' '{print $2}' && popd > /dev/null).nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
|
|
|
|
buildWASM:
|
|
name: Build WASM
|
|
runs-on: ubuntu-latest
|
|
needs: [ build ] # for ignoring bad builds
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install wasm-pack
|
|
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
|
|
- name: Build Rust for WASM
|
|
working-directory: ./finlib-wasm
|
|
run: wasm-pack build
|
|
|
|
doc:
|
|
name: Build Documentation
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: [ build, buildPy, buildWASM, buildNET ] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Pages
|
|
uses: actions/configure-pages@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Build Docs
|
|
run: cargo doc --no-deps --document-private-items -F py,wasm,ffi
|
|
|
|
- name: Add redirect
|
|
run: echo '<meta http-equiv="refresh" content="0;url=finlib/index.html">' > target/doc/index.html
|
|
|
|
- name: Remove lock file
|
|
run: rm target/doc/.lock
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
# Upload entire repository
|
|
path: './target/doc'
|
|
|
|
deploy:
|
|
name: Deploy Documentation
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: doc
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|
|
|
|
publishNPM:
|
|
name: Publish NPM
|
|
runs-on: ubuntu-latest
|
|
needs: [ buildWASM ] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install wasm-pack
|
|
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
|
|
- name: Build Rust for WASM
|
|
working-directory: ./finlib-wasm
|
|
run: wasm-pack build --release
|
|
|
|
- name: Change Package Name
|
|
working-directory: ./finlib-wasm
|
|
run: ./rename-pkg.sh
|
|
|
|
- name: Install Node
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: 22
|
|
registry-url: 'https://registry.npmjs.org' # This is just the default registry URL
|
|
|
|
- name: Publish
|
|
working-directory: ./finlib-wasm/pkg
|
|
run: npm publish --access=public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
publishRustLib:
|
|
runs-on: ubuntu-latest
|
|
name: Publish Rust Library
|
|
needs: [ build ] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Add Crates.io Credentials
|
|
run: |
|
|
cat <<EOF > ~/.cargo/credentials.toml
|
|
[registry]
|
|
token = "${{ secrets.CRATES_TOKEN }}"
|
|
EOF
|
|
|
|
- name: Cargo Publish
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: publish
|
|
args: --package finlib
|
|
|
|
publishPy:
|
|
runs-on: ubuntu-latest
|
|
name: Publish Python Library
|
|
needs: [ buildPy ] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install Python 3
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ env.python-version }}
|
|
|
|
- name: Install Maturin
|
|
working-directory: ./pyfinlib
|
|
run: python3 -m venv .venv && source .venv/bin/activate && pip3 install -r requirements.txt
|
|
|
|
- name: Publish
|
|
working-directory: ./pyfinlib
|
|
run: source .venv/bin/activate && maturin publish
|
|
env:
|
|
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |